-
Notifications
You must be signed in to change notification settings - Fork 179
Empty the acloud_cvd_temp dir on cvd reset. #1485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The acloud_cvd_temp directory contains instance lock files. If we are resetting with cvd reset, we should remove these, since we are resetting state completely anyway. This will become more important later when we are making changes to the way instance locks are acquired, and starting from a clean slate with cvd reset is more convenient than manually removing lock files.
| /* clear_instance_dirs*/ options.clean_runtime_dir)); | ||
|
|
||
| if (DirectoryExists("/tmp/acloud_cvd_temp/")) { | ||
| CF_EXPECT(RecursivelyRemoveDirectory("/tmp/acloud_cvd_temp/")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it seem worth it to delete the contents of this directory without deleting the directory itself?
I could imagine a user changing the directory permissions of this to facilitate some multi-user interaction, though it would have to be reset on every reboot anyway since /tmp is not going to be persistent. Maybe not that significant in that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be worth the effort. If we want to support the multi-user case better, then we probably need to improve the directory structure here and maybe put some of these files elsewhere, but that's a larger change.
But I'm happy to make the adjustment if you think it's worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the structure has other downsides, it breaks compatibility with python acloud. Might as well delete it then.
| CF_EXPECT(KillAllCuttlefishInstances( | ||
| /* clear_instance_dirs*/ options.clean_runtime_dir)); | ||
|
|
||
| if (DirectoryExists("/tmp/acloud_cvd_temp/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there are already 3 non-test occurrences of this string, maybe worth making a shared constant in a new file somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll be the next pr after this one. ;)
jemoreira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That directory is shared among all users in the system. cvd reset is supposed to only reset devices for the current user.
A more "correct" way for handling this is to have cvd change the ownership of each file it takes over to the current user. For that to work these files need to be created with rw permission for all. At reset time, cvd will only delete those files that are owned by the current user.
The one problem the approach mentioned above doesn't solve is acloud. It doesn't change ownership of those files, it simply reuses them if they are present. But acloud and cvd create are rarely used in the same machines these days, so it should be ok.
The acloud_cvd_temp directory contains instance lock files. If we are resetting with cvd reset, we should remove these, since we are resetting state completely anyway.
This will become more important later when we are making changes to the way instance locks are acquired, and starting from a clean slate with cvd reset is more convenient than manually removing lock files.