Skip to content

Add support for named discovery scans - #1498

Merged
khyatimahendru merged 10 commits into
faucetsdn:masterfrom
khyatimahendru:named-scans
Dec 1, 2026
Merged

khyatimahendru merged 10 commits into
faucetsdn:masterfrom
khyatimahendru:named-scans

Conversation

@khyatimahendru

@khyatimahendru khyatimahendru commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds UDMI support for named discovery scans (building on #1449) so devices can run multiple independently scheduled scans of the same protocol family—such as a nightly periodic scan alongside an on-demand targeted scan—without colliding on a single config.discovery.families.<family> key.

Covers schemas, specs, generated bindings/docs, Java pubber, and the validator/sequencer test suite (scan_named). Python clientlib and edge/spotter adoption will follow in a separate PR.

Key Changes

  • Schemas & Spec: Added scans maps to config_discovery.json and state_discovery.json, family to config_discovery_family.json (keeping a single shared FamilyDiscoveryConfig schema across families and scans), and scan to events_discovery.json, with updated specs in docs/specs/discovery*.md and regenerated bindings/fixtures (bin/gencode).
  • Pubber Scheduler: Extracted DiscoveryScheduler to run named and legacy scans with per-family mutual exclusion—sporadic scans defer FIFO in pending when busy, while periodic scans target the next upcoming grid slot and skip busy slots without error noise.
  • Validation & Contention Rules: Named scans.<name> entries require a supported family; legacy families.<family> entries reject explicit family fields; negative intervals/durations and null addresses report phase: stopped (level: 500) until corrected.
  • Legacy families Notes (@grafnu): Periodic scans now require a non-null generation (omitting it terminates the loop) and schedule the next upcoming grid slot without past-slot catch-up; non-scan-capable providers (ipv4/ipv6/ether) are skipped cleanly instead of throwing.
  • Sequencer: Added scan_named (ALPHA) covering error reporting, recovery, event.scan attribution, and state cleanup.

Testing

Verified at commit 8458ae13a (after unifying FamilyDiscoveryConfig and merging upstream/master):

  • bin/gencode check & PYTHONPATH=gencode/python python3 bin/test_generated_classes.py — passed (exit 0)
  • pubber/bin/build check (105 tests, 18 in DiscoveryManagerTest), validator/bin/build check, udmis/bin/build check (243 tests) — all passed with Checkstyle clean (exit 0)
  • bin/test_schema & bin/test_trace simple — passed (exit 0)

Author Declaration

  • I have self-reviewed this PR.

Pull request created by Gemini

Allow discovery configurations to define multiple independent scan schedules (such as concurrent periodic and on-demand scans, or distinct scans targeting the same protocol family) under `config.discovery.scans.<scan>`, reporting per-scan status in `state.discovery.scans.<scan>` and attributing emitted events via `scan` in `events_discovery`.

Named scans declare their target protocol via `family` in `config_discovery_family`, while legacy `config.discovery.families.<family>` entries preserve implicit key-based targeting and reject mismatched `family` overrides. `DiscoveryManager` coordinates both legacy family scans and named scans across shared protocol providers with mutual exclusion, preemption, and retry backoff.
Comment thread docs/specs/discovery/generation.md Resolved
Comment thread docs/specs/discovery/generation.md Resolved
Comment thread docs/specs/discovery.md Resolved
Comment thread docs/specs/discovery.md Resolved
Comment thread schema/config_discovery.json Resolved
Define named scans as a standalone primary mechanism in the discovery specs, schemas, and examples rather than framing them relative to legacy `families`. Extract scan scheduling into a concrete scheduler with FIFO deferral for busy sporadic scans, periodic retry semantics without implicit start-time fallback, and non-blocking host state locking so provider callbacks cannot deadlock `stopScan()` during config updates.
# Conflicts:
#	.gencode_hash.txt
Comment thread docs/specs/discovery/generation.md Resolved
Replace host-level lock hooks with a single-monitor outbox in DiscoveryScheduler and streamline DiscoveryManagerTest around behavioral coverage. Simplify periodic scheduling to target the next upcoming grid slot and skip busy periodic slots without emitting error noise, keeping the discovery spec and schema aligned.
# Conflicts:
#	.gencode_hash.txt
#	gencode/java/udmi/schema/DiscoveryEvents.java
#	gencode/python/udmi/schema/events_discovery.py
Comment thread schema/config_discovery.json Resolved
…scans

Introduce a dedicated schema/config_discovery_scan.json (ScanDiscoveryConfig)
with required family for discovery.scans.<name>, remove family from
schema/config_discovery_family.json so legacy discovery.families.<family>
statically forbids it, regenerate Java/Python/HTML bindings, and update
DiscoveryScheduler, DiscoverySequences, DiscoveryManagerTest, and schema
error fixtures.
khyatimahendru added a commit to khyatimahendru/udmi that referenced this pull request Nov 27, 2026
# Conflicts:
#	.gencode_hash.txt
#	gencode/java/udmi/schema/DiscoveryConfig.java
@khyatimahendru
khyatimahendru marked this pull request as ready for review December 1, 2026 06:52
@khyatimahendru
khyatimahendru requested a review from grafnu December 1, 2026 06:52
"family": {
"existingJavaType": "String"
},
"scan": {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and/or we should consider the envelope subSetKey attribute from the config proposals. If that were to exist, and be set to this same value, would we still need/want this? It's necessary information, I'm just wondering if we should go that route out of the gate instead of adding this field here.

I'm going to have the same consideration with the alarms proposal, so would be good to conceptually align on how we want to do it to have some modicum of consistency across features.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For device-originated discovery scans, we would still need scan in the payload: MQTT devices don't have access to envelope attributes like subSetKey -- they only publish to /devices/{device_id}/events/discovery -- which is the same reason family and generation already live in events_discovery.json.

That said, event.scan and envelope.subSetKey have the same regex pattern, so a UDMIS processor can project event.scan into envelope.subSetKey downstream for Pub/Sub routing & filtering if we want consistent envelope-level routing across named scans and alarms. Happy to align in a follow-up!

@grafnu

grafnu commented Dec 1, 2026 via email

Copy link
Copy Markdown
Collaborator

@khyatimahendru
khyatimahendru merged commit fe50611 into faucetsdn:master Dec 1, 2026
30 checks passed
khyatimahendru added a commit to khyatimahendru/udmi that referenced this pull request Dec 1, 2026
khyatimahendru added a commit to khyatimahendru/udmi that referenced this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants