Repository navigation
fix(promsd): look lane tags up by name, not by a computed slug - #19
Conversation
promsd turned a tag name into a slug by replacing the colon with a hyphen. NetBox deletes the colon when a client sends no slug, so a tag created in the UI got a slug promsd never asked for. NetBox answered 400 and the whole refresh failed. Each refresh now reads the slug of every lane tag from NetBox by exact name. A tag NetBox lacks, or a query NetBox refuses with 400, empties that lane only. /healthz lists those tags in unavailable_tags. Other errors still fail the refresh and keep the last snapshot. Closes dmfdeploy/dmfdeploy#795 Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
The previous commit treated every 400 on a record query as a lane tag NetBox refused. A malformed request or a 400 on a later page then replaced the last good snapshot with a partial one and cleared last_error. Lane tags are already resolved by exact name before any record query, so a missing tag is known at the lookup. A lane whose tag NetBox doesn't have is empty and /healthz lists the tag in missing_tags. No query names it. Any error on a record query fails the refresh, keeps the last good snapshot and sets last_error. Refs dmfdeploy/dmfdeploy#795 Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
The tag lookup and the record queries are separate requests. A tag created and attached between them let the records carry a tag whose lane the lookup had marked missing, so that lane served a partial set. build_payloads now takes the missing tags and gives those lanes an empty payload and no skip counts. The next refresh finds the tag and serves every record. Refs dmfdeploy/dmfdeploy#795 Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
lkirc
left a comment
There was a problem hiding this comment.
Request changes: the new tag lookup adds an undocumented permission dependency.
- src/dmf_promsd/netbox.py:105:
/api/extras/tags/requires the token to have tag-view access in NetBox, but README.md still says the token need only read services, devices, and virtual machines. A token provisioned as documented can receive an empty tag result, publish empty lanes, clearlast_error, and remain ready. Update the documented/deployed permission prerequisite (or preserve compatibility with the documented token) before merging.
NetBox hides objects a token may not view, so a token without extras.view_tag sees an empty tag list. That looked like "no lane tags exist", so promsd published empty lanes, cleared last_error and stayed ready. The refresh now fails when none of the lane tags is visible, keeps the last good snapshot, and names the missing permission in last_error. The README now lists tag view access among the token permissions. Refs dmfdeploy/dmfdeploy#795 Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
lkirc
left a comment
There was a problem hiding this comment.
Changes requested: partial tag visibility is still treated as a healthy missing-tag state.
- src/dmf_promsd/cache.py:77:
if not slugsonly fails when zero tags are visible. NetBox object permissions can constrainextras.view_tagto a subset, so a token that can seemonitoring:scrapebut notprobe/snmpmakes this refresh succeed, replaces good probe/snmp data with empty lanes, clearslast_error, and leaves/readyzready. Do not treat one returned tag as proof of full tag visibility; fail closed or explicitly require and enforce an unrestricted all-tags view permission, with a partial-visibility regression test.
Refs dmfdeploy/dmfdeploy#795 NetBox can limit tag view permission to some tags, so a hidden lane tag looks the same as a missing one. Treating it as missing published an empty lane and left the service ready. Fail the refresh instead when any lane tag is not seen, keep the last snapshot, and name the unseen tags in last_error. netbox-sot creates all three lane tags, so an unseen one is a misconfiguration or a permission gap. This removes the missing-tags path: the snapshot field, the build_payloads branch and the /healthz field. Signed-off-by: znerol2 <6800371+znerol2@users.noreply.github.com>
|
Thanks, you're right that a single visible tag proved nothing about the others. 0ebf201 fails closed instead:
Readiness still follows freshness. The issue's acceptance criterion was updated to match (dmfdeploy/dmfdeploy#795). |
lkirc
left a comment
There was a problem hiding this comment.
Approved. The current head resolves the earlier tag-visibility concern: every expected lane tag must be visible before a snapshot is replaced, preserving the last good lanes and reporting the error on any missing or hidden tag.
Summary
promsd asked NetBox for tagged records with
?tag=<slug>, and it built that slug from the tag name by turning the colon into a hyphen. That's the rule netbox-sot follows. NetBox's own rule drops the colon, so amonitoring:scrapetag created in the NetBox UI gets the slugmonitoringscrape. NetBox then answered 400, the whole refresh failed, every lane kept its last snapshot, and/readyzwent stale.NetboxClient.tag_slugs(names)resolves the lane tags with one exact-name lookup (GET /api/extras/tags/?name=…). Record queries then use the slugs NetBox returns. promsd no longer keeps its own slug rule./healthzlists it undermissing_tags, whilelast_errorstays null and/readyzstays ready.last_error. That matches existing outage behavior.The README documents
missing_tagsand the error behavior.Tests
monitoringscrape, and the legacy hyphen slug.last_erroris set.scripts/check.shpasses (26 tests).Closes dmfdeploy/dmfdeploy#795