Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,18 @@ func (d *Daemon) doStop() {
// so the daemon.shutting_down event published above flows through
// the bus to the still-subscribed plugin, which drains its
// internal queue on Stop().

// Defense-in-depth: flush identity to disk on shutdown.
// Today all identity mutations persist eagerly (GenerateIdentity
// in startNetworked and RotateKey save synchronously), but a
// future code path that mutates d.identity in-memory without a
// write would lose the change on next start. Writing here ensures
// identity on disk always reflects the shutdown state.
if d.config.IdentityPath != "" {
if err := crypto.SaveIdentity(d.config.IdentityPath, d.identity); err != nil {
slog.Warn("identity flush on shutdown failed", "error", err)
}
}
}

// startManaged detects managed networks this node belongs to and starts engines.
Expand Down
Loading