watcher: a name removed from the targets leaves the state (closes #223) #246

Merged
clawbot merged 1 commits from issue-223-remove-dropped-targets into next 2026-10-02 11:17:59 +02:00
Collaborator

Closes #223

At startup, before the first check, Run removes from the loaded state the domain, hostname and certificate entries of names no longer in DNSWATCHER_TARGETS, takes those names off each port entry's list of names, and removes a port entry left with none, so the dashboard, /api/v1/status and the startup notification count only configured names. Nothing is notified. README "State Management", and the Startup step of "Monitoring Lifecycle", say so.

Each port check, right after removing stale port entries as before, now also removes the certificate entries for an address a name no longer resolves to.

What the diff does not show:

  • A configured domain's own records are a hostname entry under the domain's name (since #244), so a hostname entry is kept for any configured name; removing a domain removes both of its entries.
  • A port entry that still names a configured name is left at startup for the port checks, as before: whether that name still has the entry's address is known only after the DNS checks.

Disclosures:

  • Judgement call: the certificate entries of a configured name none of whose nameservers answered are kept, as its port entries already were (#193): its addresses are not known, not gone.
  • Judgement call: the tests run the startup removal on a state they save and load, not Run itself, which would look the configured names up in live DNS.
  • Not changed: a check on the TLS interval alone removes nothing, as it already removed no port entries.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/dnswatcher/issues/223 At startup, before the first check, `Run` removes from the loaded state the domain, hostname and certificate entries of names no longer in `DNSWATCHER_TARGETS`, takes those names off each port entry's list of names, and removes a port entry left with none, so the dashboard, `/api/v1/status` and the startup notification count only configured names. Nothing is notified. README "State Management", and the Startup step of "Monitoring Lifecycle", say so. Each port check, right after removing stale port entries as before, now also removes the certificate entries for an address a name no longer resolves to. What the diff does not show: - A configured domain's own records are a hostname entry under the domain's name (since https://git.eeqj.de/sneak/dnswatcher/pulls/244), so a hostname entry is kept for any configured name; removing a domain removes both of its entries. - A port entry that still names a configured name is left at startup for the port checks, as before: whether that name still has the entry's address is known only after the DNS checks. Disclosures: - Judgement call: the certificate entries of a configured name none of whose nameservers answered are kept, as its port entries already were (https://git.eeqj.de/sneak/dnswatcher/issues/193): its addresses are not known, not gone. - Judgement call: the tests run the startup removal on a state they save and load, not `Run` itself, which would look the configured names up in live DNS. - Not changed: a check on the TLS interval alone removes nothing, as it already removed no port entries. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 10:18:54 +02:00
clawbot self-assigned this 2026-10-02 10:18:54 +02:00
Author
Collaborator

Review of ecbc8ac: one finding.

  1. The removal of a removed target's entries is in the port checks, where a reader does not look for it. In internal/watcher/watcher.go, checkAllPorts now ends by removing the domain, hostname and certificate entries of names no longer in DNSWATCHER_TARGETS (cleanupRemovedTargets, and the case in cleanupStaleCertificates for a name not configured). RunOnce and the README's Monitoring Lifecycle list only DNS, port and TLS checks, and nothing about ports leads a reader to the removal of domain entries. It also runs again at every DNS interval although the targets change only at a restart. Because it waits until every DNS lookup and port check of the first check is done, the dashboard and /api/v1/status keep listing the removed names, and counting them together with the new ones, until then.

    Acceptable: remove the domain, hostname and certificate entries of names not in the configuration once, before the first check, where the state is loaded or at the start of Run (using isDomain, which next now has, for the domain test). README "State Management" then says this happens at startup, and the test runs that step on a loaded state. The removal of certificate entries for an address a name no longer has stays in the port checks next to cleanupStalePorts, as it is now.

Model: opus-5-5

Review of `ecbc8ac`: one finding. 1. The removal of a removed target's entries is in the port checks, where a reader does not look for it. In `internal/watcher/watcher.go`, `checkAllPorts` now ends by removing the domain, hostname and certificate entries of names no longer in `DNSWATCHER_TARGETS` (`cleanupRemovedTargets`, and the case in `cleanupStaleCertificates` for a name not configured). `RunOnce` and the README's Monitoring Lifecycle list only DNS, port and TLS checks, and nothing about ports leads a reader to the removal of domain entries. It also runs again at every DNS interval although the targets change only at a restart. Because it waits until every DNS lookup and port check of the first check is done, the dashboard and `/api/v1/status` keep listing the removed names, and counting them together with the new ones, until then. Acceptable: remove the domain, hostname and certificate entries of names not in the configuration once, before the first check, where the state is loaded or at the start of `Run` (using `isDomain`, which `next` now has, for the domain test). README "State Management" then says this happens at startup, and the test runs that step on a loaded state. The removal of certificate entries for an address a name no longer has stays in the port checks next to `cleanupStalePorts`, as it is now. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-02 10:44:07 +02:00
clawbot force-pushed issue-223-remove-dropped-targets from ecbc8ac224 to d6a5989f8e 2026-10-02 10:47:56 +02:00 Compare
clawbot force-pushed issue-223-remove-dropped-targets from d6a5989f8e to c2736241ee 2026-10-02 10:48:49 +02:00 Compare
Author
Collaborator

Rework (c273624): the removal of a removed name's domain, hostname and certificate entries now runs once at the start of Run, before the first check, using isDomain; README "State Management" and the Startup step of "Monitoring Lifecycle" say so, the test runs that step on a loaded state, and the port checks keep only the removal of certificate entries for an address gone.

Model: opus-5-5

Rework (`c273624`): the removal of a removed name's domain, hostname and certificate entries now runs once at the start of `Run`, before the first check, using `isDomain`; README "State Management" and the Startup step of "Monitoring Lifecycle" say so, the test runs that step on a loaded state, and the port checks keep only the removal of certificate entries for an address gone. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-02 10:49:57 +02:00
Author
Collaborator

Review of cb737d0, this branch rebased onto current next: one finding.

  1. At startup a removed name is still listed in the port entries. cleanupRemovedTargets in internal/watcher/watcher.go removes the domain, hostname and certificate entries of a name no longer in DNSWATCHER_TARGETS, but the port entries loaded from the state keep that name in their list of names until the first check's port checks rewrite them. Until then the dashboard's Ports table and the ports of /api/v1/status still list the removed name and count its addresses. A removed domain is also shown there under Hostnames, not Domains, because its domain entry is already gone. So the sentence this PR adds to README "State Management" ("so the dashboard and /api/v1/status no longer list or count it") and the TODO.md entry are not true of the tree.

    Acceptable: the startup removal also takes every name no longer configured off each port entry's list of names, and removes a port entry whose list is then empty; the test checks this on the loaded state. Port entries that still name a configured name stay for the port checks, as now.

Disclosure: the branch conflicts with current next only in the TODO.md Completed Steps list; it was gated with both entries kept.

Model: opus-5-5

Review of `cb737d0`, this branch rebased onto current `next`: one finding. 1. At startup a removed name is still listed in the port entries. `cleanupRemovedTargets` in `internal/watcher/watcher.go` removes the domain, hostname and certificate entries of a name no longer in `DNSWATCHER_TARGETS`, but the port entries loaded from the state keep that name in their list of names until the first check's port checks rewrite them. Until then the dashboard's Ports table and the `ports` of `/api/v1/status` still list the removed name and count its addresses. A removed domain is also shown there under Hostnames, not Domains, because its domain entry is already gone. So the sentence this PR adds to README "State Management" ("so the dashboard and `/api/v1/status` no longer list or count it") and the `TODO.md` entry are not true of the tree. Acceptable: the startup removal also takes every name no longer configured off each port entry's list of names, and removes a port entry whose list is then empty; the test checks this on the loaded state. Port entries that still name a configured name stay for the port checks, as now. Disclosure: the branch conflicts with current `next` only in the `TODO.md` Completed Steps list; it was gated with both entries kept. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-02 10:58:33 +02:00
clawbot added 1 commit 2026-10-02 11:09:31 +02:00
At startup, before the first check, Run removes from the loaded state
the domain, hostname and certificate entries of names no longer in
DNSWATCHER_TARGETS, takes those names off each port entry's list of
names and removes a port entry left with none, so the dashboard,
/api/v1/status and the startup notification count only configured
names. A configured domain's own records, saved as a hostname entry
under its name, are kept. Nothing is notified. Each port check, next to
the removal of stale port entries, now also removes the certificate
entries for an address a name no longer resolves to, except while none
of its nameservers answered, as port entries already were.

Model: opus-5-5
clawbot force-pushed issue-223-remove-dropped-targets from c2736241ee to 1afa8d7ce2 2026-10-02 11:09:31 +02:00 Compare
Author
Collaborator

Rework (1afa8d7): the startup removal now also takes every name no longer configured off each port entry's list of names and removes a port entry left with none; a new test checks this on the loaded state, and README "State Management" says so.

Model: opus-5-5

Rework (`1afa8d7`): the startup removal now also takes every name no longer configured off each port entry's list of names and removes a port entry left with none; a new test checks this on the loaded state, and README "State Management" says so. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-02 11:09:39 +02:00
Author
Collaborator

Review passed on 1afa8d7.

Model: opus-5-5

Review passed on 1afa8d7. Model: opus-5-5
clawbot merged commit 6332b48379 into next 2026-10-02 11:17:59 +02:00
clawbot deleted branch issue-223-remove-dropped-targets 2026-10-02 11:18:00 +02:00
clawbot removed the needs-review label 2026-10-02 11:18:00 +02:00
Sign in to join this conversation.