You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
o/snapstate, o/s/backend: restart stopped services on error in stopSnapServices (#16861)
Transactionality improvement for `"stop-snap-services"` [[SNAPDENG-36594](https://warthogs.atlassian.net/browse/SNAPDENG-36594)]
* When `stopSnapServices` encounters an error mid-flight (e.g. during refresh), restart any services that were already stopped so that the snap services remain functional
* Disabled services are now queried before stopping and passed to `backend.StartServices`, so that in case of error leading to undo will only start previously enabled services.
* For remove/disable stop reasons the target is to have services stopped, so undo is skipped. **Note:** currently `undoStopSnapServices` still restarts all enabled services for a remove/disable if a future task in the change fails. We plan to change that as part of snap removal robustness improvements (at least for remove).
Add `UndoTracker` for rollback on in-flight error [[SNAPDENG-36593](https://warthogs.atlassian.net/browse/SNAPDENG-36593)]
* To better manage transactionality, add `UndoTracker` a LIFO cleanup stack that lets do handlers incrementally register undo closures for each step. On error (excluding `*state.Wait` and `*state.Retry`), the closure returned by `NewUndoTracker` executes the undos in reverse order, rolling back partial progress without knowing the undo handler's implementation details.
* The do handlers decide whether the undoes need to be registered with state lock held or released by passing either the `UndoTracker.Locked()` or `UndoTracker.Unlocked()`
* `NullUndoer` and `TODOUndoer` are also added to make it clear where undos are not needed or needed but not yet setup. This also helps in removing the need for non-nil `Undoer` check before registering undos.
* For `backend.StopServices`, the `Unlocked` adapter is used to register undoes
0 commit comments