Skip to content

Comments

cgroup: add Snap/Cgroup monitoring capabilities#12231

Closed
sergio-costas wants to merge 32 commits intocanonical:masterfrom
sergio-costas:DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support
Closed

cgroup: add Snap/Cgroup monitoring capabilities#12231
sergio-costas wants to merge 32 commits intocanonical:masterfrom
sergio-costas:DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support

Conversation

@sergio-costas
Copy link
Contributor

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 #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?

@sergio-costas sergio-costas changed the title DT-576 Add Snap/Cgroup monitoring capabilities cgroup: Add Snap/Cgroup monitoring capabilities Oct 5, 2022
@sergio-costas sergio-costas force-pushed the DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support branch 2 times, most recently from 5b4dd43 to 38c01ab Compare October 5, 2022 09:48
Copy link
Member

@Meulengracht Meulengracht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, some comments

@Meulengracht Meulengracht added the Needs Samuele review Needs a review from Samuele before it can land label Oct 6, 2022
Copy link
Contributor

@mardy mardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized I commented on the inotify code, which you only imported. :-)

So I guess you can ignore these comments, or maybe address them in a separate commit, so we clearly distinguish what changes where made by us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe onFileAdded and onFileDeleted?

@sergio-costas sergio-costas requested review from Meulengracht and mardy and removed request for Meulengracht and mardy October 7, 2022 09:16
Copy link
Member

@Meulengracht Meulengracht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all the changes, I think you missed a few, and added some comments

@sergio-costas
Copy link
Contributor Author

@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...?)

@sergio-costas
Copy link
Contributor Author

@mardy All done.

@Meulengracht
Copy link
Member

@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)

@sergio-costas
Copy link
Contributor Author

@Meulengracht This is what I see in your link, which is the same that I see in my local code...

imagen

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
Copy link
Member

@Meulengracht This is what I see in your link, which is the same that I see in my local code...

imagen

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 mardy added the Squash-merge Please squash this PR when merging. label Oct 10, 2022
@pedronis pedronis requested review from mvo5 and pedronis October 10, 2022 13:43
@pedronis pedronis changed the title cgroup: Add Snap/Cgroup monitoring capabilities cgroup: add Snap/Cgroup monitoring capabilities Oct 12, 2022
Copy link
Contributor

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a pass, bunch of style comments and some questions, we value consistency and clarity quite a bit as snapd is a fairly large codebase

@sergio-costas sergio-costas force-pushed the DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support branch 2 times, most recently from e03a383 to 25ea530 Compare October 13, 2022 10:45
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.
sergio-costas and others added 23 commits October 17, 2022 19:27
Set better names for the callbacks in the main loop
Co-authored-by: Alberto Mardegan <mardy@users.sourceforge.net>
Since it is a singleton, and the function is to get that
singleton, it makes more sense to call it MonitorSingleton().
In the methods for the CGroupMonitor class, the object was
being pased by copy instead of by reference. This MR fixes
it.
The methods MonitorFiles() and NumberOfWaitingMonitors() are
used only for tests, so it makes sense to have them in
export_test.go instead of monitor.go.
As requested, removed the singleton from the monitor.
The "monitored" dictionary's key is the folder being monitored
for the files/folders contained in each key.
Use a struct OPTIONS for the options passed to
InstancePathsOfSnap.

Also reverted the path->basepath change, since the path module
is not needed anymore.
@sergio-costas sergio-costas force-pushed the DT-576-snapd-refresh-awareness-ux-implementation_add-file-monitoring-support branch from 549993e to d7b189e Compare October 17, 2022 17:27
@sergio-costas
Copy link
Contributor Author

@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.

#12280

Which one do you prefer?

@sergio-costas
Copy link
Contributor Author

I marked this one as Draft because #12280 is a better implementation.

@sergio-costas
Copy link
Contributor Author

Closing this too because all the work is being done in #12280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Samuele review Needs a review from Samuele before it can land Squash-merge Please squash this PR when merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants