Skip to content

refactor(go.d/dyncfg): split job-name validation per domain#22247

Merged
ilyam8 merged 2 commits into
netdata:masterfrom
ilyam8:refactor/dyncfg-jobname-rules
Apr 22, 2026
Merged

refactor(go.d/dyncfg): split job-name validation per domain#22247
ilyam8 merged 2 commits into
netdata:masterfrom
ilyam8:refactor/dyncfg-jobname-rules

Conversation

@ilyam8

@ilyam8 ilyam8 commented Apr 22, 2026

Copy link
Copy Markdown
Member

Job-name validation policy is now a Callbacks[C] method so each domain declares its rule explicitly. Two reusable helpers live in the framework:

  • JobNameRuleStrict (collector — no spaces, dots, colons)
  • JobNameRuleAllowDots (SD, vnode, secretstore — allows dots in names)

Removes the package-level dyncfg.ValidateJobName default that was imposing collector rules on all callers, and lets SD/vnode/secretstore accept dotted identifiers (e.g. FQDNs).

Summary
Test Plan
Additional Information
For users: How does this change affect me?

Summary by cubic

Split job-name validation by domain in dyncfg. Collectors keep strict names; service discovery, vnode, and secretstore now accept dotted names (e.g., FQDNs).

  • Refactors

    • Move job-name checks to Callbacks[C].ValidateJobName; Handler.CmdAdd calls it before parsing.
    • Add helpers: JobNameRuleStrict (collectors) and JobNameRuleAllowDots (SD, vnode, secretstore).
    • Remove global dyncfg.ValidateJobName; update all call sites and tests.
  • Migration

    • If you implement dyncfg.Callbacks, add ValidateJobName(name string) error and use the appropriate helper.

Written for commit f6e2874. Summary will update on new commits.

Job-name validation policy is now a Callbacks[C] method so each domain
declares its rule explicitly. Two reusable helpers live in the framework:

  - JobNameRuleStrict     (collector — no spaces, dots, colons)
  - JobNameRuleAllowDots  (SD, vnode, secretstore — allows dots in names)

Removes the package-level dyncfg.ValidateJobName default that was imposing
collector rules on all callers, and lets SD/vnode/secretstore accept
dotted identifiers (e.g. FQDNs).
@github-actions github-actions Bot added area/collectors Everything related to data collection collectors/go.d area/go labels Apr 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
28.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@ilyam8 ilyam8 marked this pull request as ready for review April 22, 2026 08:53
@ilyam8 ilyam8 enabled auto-merge (squash) April 22, 2026 08:53
@ilyam8 ilyam8 merged commit 531d549 into netdata:master Apr 22, 2026
149 of 156 checks passed

@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.

No issues found across 12 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Client as External API / Netdata Cloud
    participant Handler as dyncfg.Handler (Framework)
    participant Domain as Callbacks[C] (SD, VNode, Collector)
    participant Rules as dyncfg Rules (Validation Helpers)

    Note over Client,Rules: Processing "CmdAdd" for Dynamic Configuration

    Client->>Handler: CmdAdd(Function fn)
    Handler->>Domain: ExtractKey(fn)
    Domain-->>Handler: key, job_name, ok

    Note over Handler,Domain: NEW: Domain-specific Name Validation
    Handler->>Domain: NEW: ValidateJobName(job_name)
    
    alt Domain is Collector
        Domain->>Rules: JobNameRuleStrict(job_name)
        Rules-->>Domain: error (if dots/spaces/colons)
    else Domain is SD / VNode / SecretStore
        Domain->>Rules: JobNameRuleAllowDots(job_name)
        Rules-->>Domain: error (if spaces/colons)
    end
    
    Domain-->>Handler: error status

    alt Invalid Name
        Handler->>Client: SendCode(400, "invalid job name")
    else Valid Name
        Handler->>Domain: ParseAndValidate(fn, job_name)
        Domain-->>Handler: Config object (C), error
        
        alt Valid Config
            Handler->>Domain: Start(C)
            Domain-->>Handler: success
            Handler->>Client: SendCode(200, "OK")
        else Invalid Config
            Handler->>Client: SendCode(400, "parse error")
        end
    end

    Note over Handler,Domain: Note: Validation happens before expensive payload parsing.
Loading

@ilyam8 ilyam8 deleted the refactor/dyncfg-jobname-rules branch April 22, 2026 08:56
@stelfrag stelfrag mentioned this pull request Apr 22, 2026
Ferroin pushed a commit that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection area/go collectors/go.d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants