Skip to content

Requeue nodes when their tags change - #8

Open
jmeekhof wants to merge 1 commit into
jaxxstorm:mainfrom
jmeekhof:fix/nodes-equal-tags
Open

Requeue nodes when their tags change#8
jmeekhof wants to merge 1 commit into
jaxxstorm:mainfrom
jmeekhof:fix/nodes-equal-tags

Conversation

@jmeekhof

@jmeekhof jmeekhof commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The bug

nodesEqual compares name, online state and addresses, but not tags:

https://github.com/jaxxstorm/dnsscale/blob/main/main.go#L440

Tags are what decide whether a node is managed at all, via shouldManageNode and app.required_tags. Because a tag change doesn't make nodesEqual return false, syncNodes never requeues the node, so:

  • tagging an existing device to bring it under dnsscale's management has no effect until one of its Tailscale addresses changes, or the process restarts
  • the same is true in reverse for removing a tag

Restarting is currently the reliable way to pick up a tag change, which is a surprising thing to need.

What changed

nodesEqual now compares tags as well, and the hand-rolled length-check-plus-loop over addresses becomes slices.Equal, which is what it was already doing.

One thing I noticed but did not change

Online is compared here, but nothing downstream uses it — shouldManageNode and reconcile both ignore it, so the records produced for an online and an offline node are identical. Since Online is derived as time.Since(LastSeen) < 5*time.Minute, every device crossing that threshold requeues a reconcile that rewrites byte-identical records, which costs a provider API call per address per transition.

That's arguably wasted work, but removing Online from the comparison would foreclose gating on it later, so I've left it alone. Happy to strip it in a follow-up if you'd rather.

Tests

Adds nodes_test.go covering the comparison, including tag added / removed / replaced.

go build ./..., go vet ./... and go test ./... all pass.

nodesEqual compared name, online state and addresses, but not tags.
Tags decide whether a node is managed at all via app.required_tags, so
a node that gained or lost a relevant tag was never requeued unless one
of its addresses happened to change at the same time.

In practice that means tagging an existing device to bring it under
dnsscale's management has no effect until the device's Tailscale
address changes or the process restarts.

Also switches the address comparison to slices.Equal, which is what the
hand-rolled length check and loop were doing.
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.

1 participant