cgroup: add Snap/Cgroup monitoring capabilities
This MR adds a Snap/Cgroup monitor that allows other parts of the code to wait until all the instances of a Snap have ended and it can be safely refreshed. It is the first step for a bigger MR that will allow to automagically refresh a snap after the system has notified the user that there is a refresh available and that they must close it.
This MR and a future one overrides https://github.com/snapcore/snapd/pull/12155 . The changes from that MR will be proposed in a step-by-step manner to simplify the revision process.
Thanks for helping us make a better snapd! Have you signed the license agreement and read the contribution guide?
@Meulengracht Done. About those two, I didn't miss them... I don't know why did they still appear to you. (maybe I fix them but forgot to do a push...?)
@mardy All done.
@Meulengracht Done. About those two, I didn't miss them... I don't know why did they still appear to you. (maybe I fix them but forgot to do a push...?)
They still appear here in this PR because they are not changed here, if they appear different to you, you may have messed up your branch locally. Take a look at your branch online, it appears just as here (https://github.com/sergio-costas/snapd/blob/DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support/sandbox/cgroup/monitor.go#L84)
@Meulengracht This is what I see in your link, which is the same that I see in my local code...

You asked me to remove an "if newApp.npaths < 0" that was unneeded, and it isn't there... Or was there another change to do that I missed?
@Meulengracht This is what I see in your link, which is the same that I see in my local code...
You asked me to remove an "if newApp.npaths < 0" that was unneeded, and it isn't there... Or was there another change to do that I missed?
Ah, I think we are talking past each other :-) I was talking about adding a return inside the if statement and then removing the
else, since it isn't needed.
@mardy @pedronis @mvo5 @Meulengracht I wrote an alternative patch for the monitor itself, where I fully remove the singleton. It reuses the changes in cgroup/scanning.go, which were the most reviewed by you, and completely rewrite and simplify the cgroup/monitor.go file.
https://github.com/snapcore/snapd/pull/12280
Which one do you prefer?
I marked this one as Draft because https://github.com/snapcore/snapd/pull/12280 is a better implementation.
Closing this too because all the work is being done in https://github.com/snapcore/snapd/pull/12280