hecate: auto-clear stale startup intent on lock

This commit is contained in:
Brad Stein 2026-04-04 22:37:00 -03:00
parent ba76e81ec2
commit 75ad091898

View File

@ -107,6 +107,13 @@ func (o *Orchestrator) Startup(ctx context.Context, opts StartupOptions) (err er
if readErr != nil {
return fmt.Errorf("read startup intent: %w", readErr)
}
if currentIntent.State == state.IntentStartupInProgress {
o.log.Printf("warning: detected stale startup intent from a previous interrupted run; clearing it before continuing")
if clearErr := state.MustWriteIntent(o.cfg.State.IntentPath, state.IntentNormal, "auto-clear stale startup intent", "startup"); clearErr != nil {
return fmt.Errorf("clear stale startup intent: %w", clearErr)
}
currentIntent = state.Intent{State: state.IntentNormal}
}
if currentIntent.State == state.IntentShuttingDown {
return fmt.Errorf("startup blocked: shutdown intent is active (%s)", currentIntent.Reason)
}