Remove is called after snap services are stopped

Bug #1777121 reported by Konstantinos Tsakalozos on 2018-06-15
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
High
Paweł Stołowski

Bug Description

Hi,

The remove hook runs after any services provided by the snap are stopped.

There doesn't seem to be a way to perform any cleanup by interacting with the services. Let me provide an example, in the case of microk8s (that is a full kubernetes cluster) we want to release resources such as pods, this needs to be done while the kubernetes services are up.

This bug is dicussed in the forum: https://forum.snapcraft.io/t/cleanup-before-services-go-down/5802

Thanks

Paweł Stołowski (stolowski) wrote :

Thanks for providing a use case with this bug report. We might think of a pre-remove hook, but this needs discussion (simply chaning current hook to run before services are stopped is of course not an option anymore).

As for interacting with services, you can do that with `snapctl start|stop|restart ..` (see "snapctl start --help" for an example), but I'm not suggesting to start the service back just to do the cleanup, just mentioning in case it's useful in some other case. We indeed may need a pre-remove hook to cater for all possible cases.

Changed in snapd:
status: New → Triaged
importance: Undecided → High
Samuele Pedroni (pedronis) wrote :

yes, a "pre-remove" hook seems a reasonable request, afaiu it would run before anything else in a remove and again only in the case of a full remove of the snap

Changed in snapd:
assignee: nobody → Paweł Stołowski (stolowski)
Paweł Stołowski (stolowski) wrote :
Changed in snapd:
status: Triaged → In Progress
Samuele Pedroni (pedronis) wrote :

We discussed this a bit further and is a bit unclear what the expectations would be for this new hook, in general right now with the current hook we do a best effort to stopping services and then we call it.

I understand the naive expectations for the new hook would be that the services are running, but what if they failed, or some are not running? would snapd be expected to do a best effort to getting them to run them before invoking the hook?

We should keep in mind in general remove can be used by users also on snaps in a broken state.

Would the code you imagine be running in the new hook be ok if some of the services are failed or not running, in general in the end we would ignore the hook errors and continue with remove. We do the same already with the current hook.

Samuele Pedroni (pedronis) wrote :

Basically we fear the convenience of the new hook would be misleading. Any remove related hook would need to be ready to deal with various forms of broken state possibly.

Changed in snapd:
status: In Progress → Opinion
status: Opinion → Incomplete
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers