mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
fix: update instance status BEFORE calling it
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
- migrate to list objects v2
|
||||
- split up utils.go
|
||||
- make sure nats is running before we start daemon? eigw and account service will fallback to memory versions but that breaks all functionality
|
||||
- the BlockDeviceMappings > DeviceName (/dev/xvda) is not the true volume, i think it's /dev/vda on mine. I think qmp has a query device stats which will provide block devices so we can match these up. not a blocker, but needs to be fixed eventually
|
||||
- aws ec2 modify-instance-attribute
|
||||
|
||||
### Issues to investigate
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ func (d *Daemon) restoreInstances() {
|
||||
continue
|
||||
}
|
||||
|
||||
if instance.Attributes.StopInstance || instance.Status == vm.StateStopped {
|
||||
if instance.Status == vm.StateStopped {
|
||||
slog.Info("Instance is stopped, subscribing to NATS for start commands", "instance", instance.ID)
|
||||
d.mu.Lock()
|
||||
sub, err := d.natsConn.Subscribe(fmt.Sprintf("ec2.cmd.%s", instance.ID), d.handleEC2Events)
|
||||
|
||||
@@ -474,6 +474,13 @@ func (d *Daemon) handleStartInstance(msg *nats.Msg, command qmp.Command, instanc
|
||||
}
|
||||
}
|
||||
|
||||
// Clear stop attribute before launch so WriteState inside LaunchInstance
|
||||
// persists the correct attributes. Without this, a daemon restart after
|
||||
// a stop→start cycle would see StopInstance=true and skip reconnecting QEMU.
|
||||
d.Instances.Mu.Lock()
|
||||
instance.Attributes = command.Attributes
|
||||
d.Instances.Mu.Unlock()
|
||||
|
||||
// Launch the instance infrastructure (QEMU, QMP, NATS subscriptions)
|
||||
err := d.LaunchInstance(instance)
|
||||
|
||||
@@ -487,11 +494,6 @@ func (d *Daemon) handleStartInstance(msg *nats.Msg, command qmp.Command, instanc
|
||||
return
|
||||
}
|
||||
|
||||
// Update instance attributes (LaunchInstance already transitions to StateRunning)
|
||||
d.Instances.Mu.Lock()
|
||||
instance.Attributes = command.Attributes
|
||||
d.Instances.Mu.Unlock()
|
||||
|
||||
slog.Info("Instance started", "instanceId", instance.ID)
|
||||
|
||||
if err := msg.Respond(fmt.Appendf(nil, `{"status":"running","instanceId":"%s"}`, instance.ID)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user