Description
Today, once a change/task set is added to the state engine in Pebble, the state engine will forever try to complete the task. This means it will not give up on it until it reaches a Ready()
state, even after the Pebble process restarts, or the machine reboots (as long as the state file is persisted / not deleted).
Any state not captured below means the task will continue, I believe.
// Ready returns whether a task or change with this status needs further
// work or has completed its attempt to perform the current goal.
func (s Status) Ready() bool {
switch s {
case DoneStatus, UndoneStatus, HoldStatus, ErrorStatus:
return true
}
return false
}
While reviewing Checks, and also while I am working on another overlord manager, I have seen examples where the job the change
is performing, relates to a resource that may not exist at some point in the future (e.g. after a restart)
Examples:
-
Imagine that as a result of a HTTP API request or Pebble client command, some data is sent to the Pebble daemon, which is processing this data stream through a
change
request. If an interruption happens, and the machine is powered down mid operation, and powered up 1 day later, the original context of the change is no longer relevant. -
Imagine a state machine performing hardware related actions using
changes
. If a hardware device such as an USB device is connected, which triggers work to be performed as achange
, an interruption occurs (power cut / crash), and the machine restarts with the hardware no longer attached, the original context of the change is no longer relevant.
I am wondering whether it could make sense to better support this in the state code.
For example: This could be a type of Change/Task or Change/Task attribute, where the state engine understand both the boot context (distinguish between reboots) and process context (distinguish between process restarts), and auto cancel them if the contexts no longer applies (without triggering undo - which also no longer makes sense) ?
Activity