Cleanup before services go down


#1

Hi,

The remove hook runs after any services provided by the snap are stopped. Is there a way to run some cleanup code before the services are down?

Consider this case, microk8s would like to stop all pods running before the services are stopped. Without this cleanup step docker related mountpoints are not released and the removal of the snap fails.

Thanks


#2

Shouldn’t this be done by the service when it gets a SIGTERM from systemd?


#3

The services may be stopped only to be restarted again in the future. I shouldn’t clean the infrastructure in this case. Is there a way to know that the SIGTERM is caused by the snap being removed and not a stop/start systemd operation?


#4

This would have to be a pre-remove hook or some such. That said, according to the docs on remove it runs before the last revision is removed? It explicitly mentions shutting a service down gracefully so I wonder if that is a documentation or an implementation bug?


#5

Is there any update on this? Is this a bug, or a missing feature?


#6

@kjackal can you confirm the remove hook runs after the services are stopped? So you can’t use it for this? If that’s the case I suggest you file a bug for this.