Documentation
¶
Overview ¶
Package nodeidentity owns the process-wide identity lock for a running node. It deliberately keys locks by node kind and stable identity: one physical node per host, while a VM on that host may hold a separate VM lock.
Index ¶
Constants ¶
const ( KindPhysical = "physical" KindVM = "vm" )
Variables ¶
var ErrAlreadyRunning = errors.New("node identity already running")
ErrAlreadyRunning identifies a live process holding the same node identity. Callers should use errors.Is instead of parsing platform-specific errors.
Functions ¶
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is held for the lifetime of a daemon process.
func Acquire ¶
Acquire obtains the exclusive local lock for kind/identity. The OS-level advisory lock is released automatically if the process exits unexpectedly.
Only contention is reported as ErrAlreadyRunning. A lock that cannot be taken for any other reason — an unreadable config directory, a volume that refuses locks — comes back as itself, because callers draw opposite conclusions from the two: a daemon treats ErrAlreadyRunning as "another node is up" and stands down, and Held reports it as "the row has an owner". Reporting an I/O error as contention is how a broken environment turned into a false demotion.