Skip to content

Commit

Permalink
fix: allow setting provisioning info for dying machine
Browse files Browse the repository at this point in the history
We have a potential race where a machine can transition to "dying" while
it is being provisioned. When this happens the provisioner can not
record provisioning info against the machine. If this occurs during
model destruction, we are effectively blocked, because the provisioner
can't come back around to deprovisioning the machine and allowing its
life cycle to advance.

This softens the SetProvisioned checks to ensure a machine is not dead,
instead of not dying or dead. This should give the provisioner the
change to record the instance data, then come around immediately to
deprovision.
  • Loading branch information
manadart committed Dec 5, 2024
1 parent 690aab0 commit f0bbc51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions state/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ func (m *Machine) SetProvisioned(
{
C: machinesC,
Id: m.doc.DocID,
Assert: append(isAliveDoc, bson.DocElem{Name: "nonce", Value: ""}),
Assert: append(notDeadDoc, bson.DocElem{Name: "nonce", Value: ""}),
Update: bson.D{{"$set", bson.D{{"nonce", nonce}}}},
}, {
C: instanceDataC,
Expand All @@ -1395,10 +1395,10 @@ func (m *Machine) SetProvisioned(
return nil
} else if err != txn.ErrAborted {
return err
} else if alive, err := isAlive(m.st, machinesC, m.doc.DocID); err != nil {
} else if aliveOrDying, err := isNotDead(m.st, machinesC, m.doc.DocID); err != nil {
return err
} else if !alive {
return machineNotAliveErr
} else if !aliveOrDying {
return errDeadOrGone
}
return fmt.Errorf("already set")
}
Expand Down

0 comments on commit f0bbc51

Please sign in to comment.