Skip to content

Reload host labels from the Agent’s active config file - #24117

Open
stelfrag wants to merge 5 commits into
netdata:masterfrom
stelfrag:fix-reload-labels-config-path
Open

stelfrag wants to merge 5 commits into
netdata:masterfrom
stelfrag:fix-reload-labels-config-path

Conversation

@stelfrag

@stelfrag stelfrag commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator
Summary
  • Fix startup and reload-labels to read host labels from the config file the Agent loaded, including -c FILE, and remove labels deleted from that file.
Test Plan
  1. Create /tmp/netdata-repro.conf:
    [host labels]
        repro_label = first
  2. Start the Agent with netdata -c /tmp/netdata-repro.conf.
  3. Check http://localhost:19999/api/v1/info for host_labels.repro_label. Before the fix, the label is absent because the Agent reads labels from the default config path.
  4. Change first to second in that file and run netdatacli reload-labels. Before the fix, the new value is not loaded. After the fix, host_labels.repro_label is second.
  5. Remove the entire [host labels] section and run netdatacli reload-labels again. After the fix, repro_label disappears.

Summary by CodeRabbit

  • New Features

    • Host labels are now loaded from the configuration used to start the Agent, including a file specified with -c.
    • Configuration sections can be reloaded from the primary configuration file, with the stock configuration used as a fallback when applicable.
  • Bug Fixes

    • Reloading a section now removes options that are no longer present in the file, including when the section itself is absent.
    • If a configuration reload fails, existing in-memory values remain in use.

Host labels were always re-read from the compiled-in CONFIG_DIR/netdata.conf,
so with `netdata -c FILE` the labels came from the wrong file, both at startup
and on `netdatacli reload-labels`.

netdata_conf_load() now remembers the files it read (the -c file made
absolute, or the user file with the stock fallback), and the labels reload
uses them. A targeted inicfg_load() clears its section once before reading,
so removing the whole [host labels] section also removes the labels.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c89da5c4-f3fe-4d51-9d00-e41a22e2f7e3

📥 Commits

Reviewing files that changed from the base of the PR and between 4c4618b and 9e42438.

📒 Files selected for processing (6)
  • src/cli/README.md
  • src/daemon/config/netdata-conf.c
  • src/daemon/config/netdata-conf.h
  • src/daemon/unit_test.c
  • src/database/rrdhost-labels.c
  • src/libnetdata/inicfg/inicfg_conf_file.c

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds targeted INI section replacement and a daemon API for reloading a section from retained configuration paths. Host-label loading uses the new API, and the CLI description specifies which startup configuration file supplies labels.

Changes

Configuration section reload

Layer / File(s) Summary
Targeted INI section replacement
src/libnetdata/inicfg/inicfg_conf_file.c, src/daemon/unit_test.c
Targeted loads with overwrite enabled clear the requested section before parsing. Unit tests cover option removal, repeated sections, missing-file failure, and preservation of other sections.
Configuration path tracking and section reload
src/daemon/config/netdata-conf.h, src/daemon/config/netdata-conf.c
The daemon retains primary and optional stock configuration paths and declares netdata_conf_reload_section. The function reloads from the primary path and attempts the stock path only when the primary has never loaded.
Host-label reload integration
src/database/rrdhost-labels.c, src/cli/README.md
Host-label loading uses netdata_conf_reload_section. The CLI description identifies the startup configuration file, including the -c file when provided.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant HostLabels as rrdhost_load_config_labels
  participant Config as netdata_conf_reload_section
  participant INI as inicfg_load
  HostLabels->>Config: reload host-label section
  Config->>INI: load section from primary configuration
  alt primary has not loaded and fallback exists
    Config->>INI: load section from stock configuration
  end
  Config-->>HostLabels: reload result
Loading

Merge Risk: ⚪ Minimal · up to 9e424

Reloading labels uses the startup configuration and removes labels deleted from it. No actionable issue remains from the reviewed change.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9e424

The change keeps label reloads tied to the selected configuration file and does not demonstrate a new remotely controllable entrypoint. The main concern is failure containment: a read failure after opening the file can discard previously valid label configuration. Exposure appears limited, but exceptional path handling and all reload callers were not fully verified.

Retained concerns

  • Low · reliability · inferred: Targeted reload discards the live section before establishing that the file can be read completely. A read error before the matching section header can therefore erase last-known-good configuration labels and publish their removal as a successful refresh. This broadens the earlier header-triggered clearing failure mode, although nontransactional parsing itself predates the PR. Missing-file failures remain contained because opening precedes deletion.
Security review details

Security Blast Radius

  • inferred — The directly demonstrated mutable scope is the selected host-label configuration section and the Agent's localhost label set. The inspected command accepts neither a replacement file path nor a host selector. Downstream use of these labels as security or routing policy was not established.

Trust Boundaries and Controls

  • observed — The reload command ignores its arguments, while the configuration module selects retained startup paths and the label loader supplies a fixed section name. This prevents command arguments from directly selecting arbitrary files or configuration sections in the inspected path; filesystem permissions and command-transport authorization were not independently verified.

Resilience and Maintainability Implications

  • observed — Failure containment distinguishes opening from reading: fopen failure leaves old options intact, but the parser mutates live state and reports success after its read loop without checking ferror. The label loader then enumerates that state regardless of the reload API's boolean result.

Hardening Proposals

  • proposed — Parse the requested section into temporary state and commit replacement only after a complete successful read. Preserve intentional empty-section replacement while retaining last-known-good values on actual read errors.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: reloading host labels from the Agent's active configuration file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Architecture diagram
sequenceDiagram
    participant CLI as netdata CLI
    participant Agent as Netdata Agent
    participant Config as Config Loader
    participant File as Config Files
    participant Labels as Host Labels

    Note over CLI,Labels: Host Labels Configuration Flow

    Agent->>Config: Start with config file spec (-c or default)
    Config->>File: Read primary config file
    alt Custom config (-c FILE)
        Config->>Config: Store absolute path as primary
        File-->>Config: Primary config content
    else Default config
        Config->>File: Try user netdata.conf
        alt User config not found
            Config->>File: Load stock netdata.conf
            Config->>Config: Store fallback path
            File-->>Config: Stock config content
        else User config found
            File-->>Config: User config content
        end
    end
    
    Config->>Config: Track active config file paths
    Config-->>Agent: Config loaded

    Note over Agent,Labels: Runtime label reload (reload-labels command)

    CLI->>Agent: reload-labels command
    Agent->>Labels: Trigger label reload
    Labels->>Config: Request section reload
    
    Config->>File: Re-read [host labels] section from primary config
    alt Section found in primary
        File-->>Config: Section data
        Config->>Config: Replace existing section options
        Config-->>Labels: Updated section data
    else Section not in primary, fallback exists
        Config->>File: Re-read from fallback config
        alt Found in fallback
            File-->>Config: Section data
            Config->>Config: Replace existing section options
            Config-->>Labels: Updated section data
        else Not found anywhere
            Config-->>Config: Log warning, keep in-memory values
            Config-->>Labels: Existing data retained
        end
    end
    
    Labels->>Labels: Process section options
    Labels-->>Agent: Labels updated (including removed ones)
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/daemon/config/netdata-conf.c Outdated
Comment thread src/daemon/config/netdata-conf.c Outdated
Comment thread src/daemon/config/netdata-conf.c
test_inicfg_section_reload() covers a dropped option, repeated section
headers, a missing file and a removed section; master fails the repeated
and removed cases.
After the user netdata.conf has been read once, the reload no longer falls
back to the stock file: it normally has no [host labels], so it wiped the
labels. The stock fallback stays for agents that never read a user file.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/daemon/unit_test.c Outdated
Comment thread src/daemon/unit_test.c
Comment thread src/daemon/unit_test.c Fixed
Comment thread src/daemon/unit_test.c Fixed
The fixture used a fixed /tmp name, which is predictable and missing on
Windows, and a write failure called fatal(). Use TMPDIR (or P_tmpdir) with
mkstemp(), and fail the test instead when the fixture cannot be written.
The helper reopened the fixture with fopen("w"), which would create it
with mode 0666 if it went missing. Open the mkstemp() file with O_TRUNC
and no O_CREAT instead.
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

Comment thread src/daemon/unit_test.c Dismissed
@stelfrag
stelfrag marked this pull request as ready for review October 2, 2026 12:28
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Reload host labels from the Agent’s active config file

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Read host labels from the Agent’s active config file, including a file specified with -c.
• Remove labels deleted from the file while preserving in-memory labels if re-reading fails.
• Test targeted section reloads and clarify reload-labels behavior in the CLI documentation.
Diagram

graph TD
  A["Startup or CLI"] --> B["Label refresh"] --> C["Config source"] --> D{"Primary readable?"}
  D -->|Yes| E["Section parser"] --> F["Host labels"]
  D -->|No, never loaded| G["Stock fallback"] --> E
  D -->|No, loaded before| F
  G -->|Unavailable| F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Pass the config path directly to label loading
  • ➕ Keeps the parser-facing change local to host labels.
  • ➖ Duplicates startup path and fallback decisions in the label subsystem.
  • ➖ Makes future section reloads repeat the same source-selection logic.

Recommendation: Keep the centralized config-section reload API: it owns the active path and fallback rules, while the parser owns section replacement. The direct-path alternative is narrower but would split config-source policy across components.

Files changed (6) +173 / -26

Enhancement (1) +3 / -0
netdata-conf.hExpose targeted config-section reload +3/-0

Expose targeted config-section reload

• Declares the API for re-reading a section from the config source selected at startup.

src/daemon/config/netdata-conf.h

Bug fix (3) +77 / -25
netdata-conf.cRemember startup config paths for section reloads +64/-9

Remember startup config paths for section reloads

• Retains the primary and stock config paths, making a relative '-c' path absolute before the Agent changes directories. Adds targeted section reloads that use the stock fallback only if the user file has never loaded and preserve in-memory values when re-reading fails.

src/daemon/config/netdata-conf.c

rrdhost-labels.cReload labels through the active config source +1/-8

Reload labels through the active config source

• Replaces the compiled-in default-path read with the config module’s targeted host-label reload before collecting labels.

src/database/rrdhost-labels.c

inicfg_conf_file.cClear a targeted section once before parsing +12/-8

Clear a targeted section once before parsing

• After a file opens successfully, clears the targeted section before parsing so deleted options and entire removed sections disappear. Avoids clearing it again when a section header repeats.

src/libnetdata/inicfg/inicfg_conf_file.c

Tests (1) +92 / -0
unit_test.cTest section replacement and failed reloads +92/-0

Test section replacement and failed reloads

• Adds a temporary-file test for removed options, repeated section headers, missing files, and removed sections. Checks that unrelated sections and values survive targeted or failed reloads.

src/daemon/unit_test.c

Documentation (1) +1 / -1
README.mdClarify the source used by reload-labels +1/-1

Clarify the source used by reload-labels

• Documents that 'reload-labels' reads the config file the Agent started with, including a file supplied through '-c'.

src/cli/README.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (2)

Grey Divider


Action required

1. A read error can erase active host labels 📜 Skill insight ☼ Reliability
Description
inicfg_load() now deletes the existing section before reading the replacement, but it does not
check ferror(fp) when fgets() stops and returns success even after a read error. If the config
file opens but a later read fails, reload-labels treats the incomplete section as authoritative
and prunes labels that were not read.
Code

src/libnetdata/inicfg/inicfg_conf_file.c[R193-195]

+            SECTION_LOCK(sect);
+            inicfg_option_remove_and_delete_all(sect, true);
+            SECTION_UNLOCK(sect);
Evidence
The new deletion precedes the read loop. The loop does not distinguish end-of-file from a read
error, and the loader returns success afterward; the host-label reload then removes labels absent
from the section left in memory.

src/libnetdata/inicfg/inicfg_conf_file.c[188-200]
src/libnetdata/inicfg/inicfg_conf_file.c[329-331]
src/database/rrdhost-labels.c[248-260]
Skill: collectors-authoring

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A targeted section reload deletes existing options before confirming that the replacement file was read successfully.

## Fix Focus Areas
- src/libnetdata/inicfg/inicfg_conf_file.c[188-200]
- src/libnetdata/inicfg/inicfg_conf_file.c[329-331]

## Recommended Fix
Check for stream read errors and only replace the existing section after a complete, successful read. Return failure without changing the section when reading fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Reload warnings hide the file error 📜 Skill insight ◔ Observability
Description
netdata_conf_reload_section() warns that it cannot reload a section but omits the observed file
error for both the primary and fallback attempts. When a file is missing or unreadable, the warning
names the paths but does not distinguish the cause, leaving operators unable to tell which access
failed and why.
Code

src/daemon/config/netdata-conf.c[R85-88]

+    if(try_fallback)
+        nd_log(NDLS_DAEMON, NDLP_WARNING,
+               "CONFIG: cannot reload section [%s] from '%s' or '%s', using the values in memory",
+               section, netdata_conf_files.primary, netdata_conf_files.fallback);
Evidence
The added warnings identify the reload operation and target paths, but provide no observed file
error or other detail explaining the failed attempts.

src/daemon/config/netdata-conf.c[73-92]
Skill: collectors-authoring

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Section-reload warnings identify the attempted files but omit the observed errors.

## Fix Focus Areas
- src/daemon/config/netdata-conf.c[73-92]

## Recommended Fix
Capture each load failure's cause before another attempt changes it, and include the relevant observed error alongside the expected reload source in the warning.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Windows drive-relative labels do not reload 🐞 Bug ≡ Correctness
Description
netdata_conf_path_absolute_strdupz() treats a path such as C:netdata.conf as relative and joins
it to getcwd(), even though it is relative to drive C’s current directory. Startup reads the
original -c path, but reload-labels reads the differently constructed path after the Agent
changes directory.
Code

src/daemon/config/netdata-conf.c[33]

+    return filename_from_path_entry_strdupz(cwd, path);
Evidence
The path classifier explicitly recognizes C:x as drive-relative, but the resolver joins every
non-absolute path to getcwd(). Initial loading uses filename while reloading uses the joined
primary path; startup later changes directory.

src/daemon/config/netdata-conf.c[13-33]
src/daemon/config/netdata-conf.c[43-47]
src/daemon/config/netdata-conf.c[73-76]
src/daemon/main.c[1159-1160]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Windows drive-relative `-c` paths are joined to the process working directory, producing a different path for reload.
## Fix Focus Areas
- src/daemon/config/netdata-conf.c[13-33]
## Recommended Fix
Resolve drive-relative paths using Windows path semantics before storing the reload path, and test that startup and reload address the same file.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Labels stay stale when the directory is unknown 🐞 Bug ☼ Reliability
Description
netdata_conf_path_absolute_strdupz() stores a relative -c path unchanged when getcwd() fails.
The initial load can succeed from the startup directory, but after the Agent changes directory,
reload-labels tries that path elsewhere and retains the old labels.
Code

src/daemon/config/netdata-conf.c[R28-30]

+    if(!getcwd(cwd, sizeof(cwd))) {
+        netdata_log_error("CONFIG: cannot get the current directory, '%s' will be reloaded as given.", path);
+        return strdupz(path);
Evidence
The failure branch retains the relative path, while initial loading uses the original filename and
section reload uses the retained path. The Agent changes working directory during startup, and an
unsuccessful re-open leaves the section in memory.

src/daemon/config/netdata-conf.c[23-33]
src/daemon/config/netdata-conf.c[43-47]
src/daemon/config/netdata-conf.c[73-94]
src/daemon/main.c[1159-1160]
src/libnetdata/inicfg/inicfg_conf_file.c[176-182]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed `getcwd()` leaves a relative config path that resolves differently after startup changes directory.
## Fix Focus Areas
- src/daemon/config/netdata-conf.c[23-33]
- src/daemon/config/netdata-conf.c[43-47]
## Recommended Fix
Do not proceed with an unresolvable relative reload path. Resolve and retain the startup file location before changing directory, or fail loading that path with a clear error.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 271 rules
✅ Skills: 11 invoked
  collectors-authoring
  repo-skill-authoring
  collectors-go-framework-v2
  collectors-metadata-yaml
  triage-support-bundle
  integrations-lifecycle
  collectors-go-design
  health-alert-authoring
  topology-authoring
  collectors-prometheus-profiles
  docs-learn-site-structure
✅ Cross-repo context — repo relationships
Review mode: ⚖️ Balanced: This changes configuration loading and reload semantics across multiple C components, affecting startup behavior and host-label state, so it carries meaningful correctness and regression risk but is not clearly dense enough to warrant redundant extended review.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +193 to +195
SECTION_LOCK(sect);
inicfg_option_remove_and_delete_all(sect, true);
SECTION_UNLOCK(sect);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. A read error can erase active host labels 📜 Skill insight ☼ Reliability

inicfg_load() now deletes the existing section before reading the replacement, but it does not
check ferror(fp) when fgets() stops and returns success even after a read error. If the config
file opens but a later read fails, reload-labels treats the incomplete section as authoritative
and prunes labels that were not read.
Agent Prompt
## Issue description
A targeted section reload deletes existing options before confirming that the replacement file was read successfully.

## Fix Focus Areas
- src/libnetdata/inicfg/inicfg_conf_file.c[188-200]
- src/libnetdata/inicfg/inicfg_conf_file.c[329-331]

## Recommended Fix
Check for stream read errors and only replace the existing section after a complete, successful read. Return failure without changing the section when reading fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +85 to +88
if(try_fallback)
nd_log(NDLS_DAEMON, NDLP_WARNING,
"CONFIG: cannot reload section [%s] from '%s' or '%s', using the values in memory",
section, netdata_conf_files.primary, netdata_conf_files.fallback);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Reload warnings hide the file error 📜 Skill insight ◔ Observability

netdata_conf_reload_section() warns that it cannot reload a section but omits the observed file
error for both the primary and fallback attempts. When a file is missing or unreadable, the warning
names the paths but does not distinguish the cause, leaving operators unable to tell which access
failed and why.
Agent Prompt
## Issue description
Section-reload warnings identify the attempted files but omit the observed errors.

## Fix Focus Areas
- src/daemon/config/netdata-conf.c[73-92]

## Recommended Fix
Capture each load failure's cause before another attempt changes it, and include the relevant observed error alongside the expected reload source in the warning.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

return strdupz(path);
}

return filename_from_path_entry_strdupz(cwd, path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Windows drive-relative labels do not reload 🐞 Bug ≡ Correctness

netdata_conf_path_absolute_strdupz() treats a path such as C:netdata.conf as relative and joins
it to getcwd(), even though it is relative to drive C’s current directory. Startup reads the
original -c path, but reload-labels reads the differently constructed path after the Agent
changes directory.
Agent Prompt
## Issue description
Windows drive-relative `-c` paths are joined to the process working directory, producing a different path for reload.
## Fix Focus Areas
- src/daemon/config/netdata-conf.c[13-33]
## Recommended Fix
Resolve drive-relative paths using Windows path semantics before storing the reload path, and test that startup and reload address the same file.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +28 to +30
if(!getcwd(cwd, sizeof(cwd))) {
netdata_log_error("CONFIG: cannot get the current directory, '%s' will be reloaded as given.", path);
return strdupz(path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. Labels stay stale when the directory is unknown 🐞 Bug ☼ Reliability

netdata_conf_path_absolute_strdupz() stores a relative -c path unchanged when getcwd() fails.
The initial load can succeed from the startup directory, but after the Agent changes directory,
reload-labels tries that path elsewhere and retains the old labels.
Agent Prompt
## Issue description
A failed `getcwd()` leaves a relative config path that resolves differently after startup changes directory.
## Fix Focus Areas
- src/daemon/config/netdata-conf.c[23-33]
- src/daemon/config/netdata-conf.c[43-47]
## Recommended Fix
Do not proceed with an unresolvable relative reload path. Resolve and retain the startup file location before changing directory, or fail loading that path with a clear error.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants