Skip to content

Add Recover for startup cleanup after an unclean exit - #3

Closed
johnmaguire wants to merge 1 commit into
mainfrom
recover
Closed

johnmaguire wants to merge 1 commit into
mainfrom
recover

Conversation

@johnmaguire

Copy link
Copy Markdown
Member

Adds Recover(ctx, Options) (changed bool, err error), a startup recovery for a process whose predecessor under the same identity exited without Close.

Consumers today keep a marker file to decide whether a crashed predecessor left DNS configuration worth building a Manager to clear. NRPT rules, State keys, and resolver files already name their identity, and Windows adapter values are attributed through the rules that record the adapter, so the library can answer that itself. Recover probes the host without taking a lock or starting a change source, returns at once when nothing of the identity's remains, and otherwise runs the same final cleanup Close does, under the identity and host locks and bounded by ShutdownTimeout. Unlike Close it returns ErrManagerAlreadyRunning when a live holder keeps the identity, because the caller asked for removal and got none.

  • Backend.HasArtifacts is the read half of Clear on each backend; noop finds nothing.
  • New and Recover share construction through build.
  • Known limit, documented: a reload or Group Policy notification a predecessor still owed after deleting its last rule leaves nothing to find.
  • dnsconfigctl recover; the catch-all smoke rows now clean up a detached set with Recover and require a second call to find nothing.

Smoke runs on this branch passed every row on macOS and Windows.

Consumers keep a marker file to decide whether a crashed predecessor left
DNS configuration worth building a Manager to clear. NRPT rules, State keys,
and resolver files already name their identity, and Windows adapter values
are attributed through the rules that record the adapter, so the library
can answer that itself: Recover probes the host without locks, returns at
once when nothing of the identity's remains, and otherwise runs Close's
final cleanup. A live holder is returned as ErrManagerAlreadyRunning
because the caller asked for removal.

Backends gain HasArtifacts, the read half of Clear. The catch-all smoke rows
clean a detached set up with Recover and require a second call to find
nothing.
@johnmaguire
johnmaguire marked this pull request as ready for review October 27, 2026 03:22
@johnmaguire

Copy link
Copy Markdown
Member Author

@matt-defined What do you think about this approach to remove the marker file that dnclient & nebula are currently writing?

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