feat(discovery): report configured scope in metadata - #132
Merged
Conversation
The server knew a discovery datasource existed but not what it covered. Its integration row carries only routing — datasource_key, agent_type, connection_mode — while allowed_cidrs stayed in the agent's local config and was never reported. That blocks two things. A scheduler has to be told the ranges separately, so server and agent can drift: the server asks for a sweep the agent refuses as out of scope, and the refusal reads as a bug in discovery rather than a configuration mismatch. And the coverage report has no denominator — 'how many machines are there' needs the intended scope, not just whatever answered. Reported the same way #129 added pack_versions, so the channel already existed. An unrestricted datasource omits the field rather than reporting an empty list, so 'covers everything' stays distinguishable from 'covers nothing'.
There was a problem hiding this comment.
Code Review
This pull request introduces a scope method to the Proxy struct to collect and report allowed CIDRs and hostnames as allowed_cidrs in the metadata. It also adds unit tests to verify this functionality. The review feedback suggests improving the test assertions in TestCollectMetadata_ReportsScope by using a map for exact lookups instead of string containment checks to avoid false positives.
RamanKharchee
approved these changes
Aug 10, 2026
PrashantBtkl
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The server knows a discovery datasource exists but not what it covers.
Checking the live dev database, the auto-registered integration for our testbed collector carries only routing information:
allowed_cidrslives in the agent's local config and is never reported, so nothing server-side knows which ranges that collector is responsible for.Why it matters before the scheduler lands
A scheduler cannot be built on this. nudgebee-enterprise#35405's scheduler has to know which CIDRs to sweep. Configured separately from the agent, the two drift: the server asks for a sweep the agent refuses as out of scope, and that refusal reads as a bug in discovery rather than a configuration mismatch. Someone will lose an afternoon to it.
The coverage report has no denominator. "412 machines, 32 gaps" requires the intended scope. Without it the server only knows what happened to answer, which is the difference between an inventory and a guess — and that report is the entire deliverable of this phase.
What this does
Adds
allowed_cidrstoCollectMetadata, the same way #129 addedpack_versions— the channel already exists, so this is a small addition rather than new plumbing.An unrestricted datasource omits the field rather than reporting an empty list, so the server can distinguish "covers everything" from "covers nothing". Those need different handling and an empty list conflates them.
Bare hostnames in the allowlist are reported as configured, since they are resolved per request rather than at configure time and there is no address to report.
Refs #113, #114
Type of change
How Has This Been Tested?
make validatepasses, lint clean, discovery at 80.1% coverage./32so the server sees consistent notation[]pack_versionsandactionsmetadata tests still pass, so nothing else in the payload shiftedNot yet consumed server-side — that belongs with #35405, which is where the scheduler and the coverage report get built. This is the agent half, done first so the server work has something to read.
Checklist
make validatepasses (fmt + lint + test)