fix: dropped state

This commit is contained in:
Julian Sommer
2026-03-13 03:53:38 +00:00
parent e6a09d371c
commit 2b455e365e
+4 -3
View File
@@ -454,11 +454,12 @@ func (d *Daemon) handleStopOrTerminateInstance(msg *nats.Msg, command types.EC2I
if d.jsManager != nil {
if isTerminate {
// Write to terminated KV bucket (auto-expires after 1 hour via TTL).
// On failure, continue cleanup — VM is already stopped, keeping it
// in the local map just delays data loss to the next restart.
// If this fails, keep the instance in local state so DescribeInstances
// still sees it and restoreInstances can retry the KV migration.
if err := d.jsManager.WriteTerminatedInstance(inst.ID, inst); err != nil {
slog.Error("Failed to write terminated instance to KV, instance will not appear in DescribeInstances",
slog.Error("Failed to write terminated instance to KV, keeping in local state for retry",
"instanceId", inst.ID, "err", err)
return
}
} else {
// Write to shared KV first — if daemon crashes after this but