Skip to content
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

Implement disable default mounts via command line #23254

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

arixmkii
Copy link
Contributor

Fixes #22364

This PR adds specific handling of the command line arguments -v "" - special handling for empty string. -v being present suppresses defaults from the config, so, it is sufficient to implement it as no-op to achieve empty mounts. This happens as early as possible (before any machine specific logic would be called).

Additional change is to allow using QEMU w/o virtiofsd binary if there are no mounts needed and the binary will not be used to run additional daemon.

And the final change is to disable default mounts for e2e tests, which are not supposed to have any mounts. Implementation is a bit hacky it checks if the command is machine init and then traverses args to see if there are mounts requested, if no mounts in the list it will inject empty mount arguments and continue.

Does this PR introduce a user-facing change?

Allow `podman machine init` w/o default mounts via command line arguments `-v ""`

@mheon
Copy link
Member

mheon commented Jul 11, 2024

I don't think the -v "" syntax will work. A new flag (--no-default-mounts or similar) would be more acceptable.

@mheon
Copy link
Member

mheon commented Jul 11, 2024

@baude PTAL

@arixmkii
Copy link
Contributor Author

-v "" was tested on Windows host. So, from technical standpoint it works. It might still be not desirable from the API perspective standpoint.

@mheon
Copy link
Member

mheon commented Jul 11, 2024

That's mostly my concern - feels like poor user interface

@arixmkii
Copy link
Contributor Author

I'm open to reimplement it, when the final decision is agreed within the team.

@mheon
Copy link
Member

mheon commented Jul 11, 2024

@Luap99 @ashley-cui @l0rd Thoughts on this one? I'm pretty firmly in favor of a separate flag but could be convinced otherwise

@rhatdan
Copy link
Member

rhatdan commented Jul 11, 2024

Since I can find no precedence for this, I guess I would go with new option.

But why not just edit containers.conf and remove the volumes?

@ashley-cui
Copy link
Member

I'm on team edit containers.conf, but okay with a new flag.

@l0rd
Copy link
Member

l0rd commented Jul 12, 2024

@arixmkii can you please provide more details on the use case? What's the use case that requires to disable the defaults volumes? And why editing the conf file doesn't work in this case?

@arixmkii
Copy link
Contributor Author

Editing config would do the trick. I just expected there to be API to achieve the same effect, but there was no. Right now there is no sure way to init machine with mounts disabled w/o checking config in advanced. Example - running e2e machine tests would always use mounts in all tests with the default configuration and there is no way to force this behavior in tests only.

This actually could be considered as niche or minor issue. I created original issue about this and as this was not strictly rejected I submitted this follow up. If this is considered as not needed both this PR and the issue can be closed with "won't implement." In this case I can resubmit only a change for checking if mounts are requested before checking virtiofsd dependency.

@l0rd my scenario is the system, where I reinstall (often with prune everything uninstall or sometimes restoring that system from snapshot) Podman releases rebuilt from main head often and I can't have mounts operational. It's very specific and can be mitigated with some sort of automation on my side.

@Luap99
Copy link
Member

Luap99 commented Jul 12, 2024

I am fine with -v "" and actually would prefer it over a new option. I don't find the argument just edit the config very strong. You can have more than one machine and may not want mounts for only one so changiing th econfig over and over is not helpful to users.

Comment on lines 201 to 204
if len(cmdArgs) >= 2 && cmdArgs[0] == "machine" && cmdArgs[1] == "init" && !slices.Contains(cmdArgs, "-v") {
tailArgs := append([]string{"-v", ""}, cmdArgs[2:]...)
cmdArgs = append([]string{"machine", "init"}, tailArgs...)
}
Copy link
Member

Choose a reason for hiding this comment

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

This does not look right. First of all this argument manipulation happens in the wrong place. It would need to happen for buildCmd() in the machineInit type.

Second I really really think tests must use the default volumes, it is critical that these mounts work. Most tests may not use them but it is still important that our code works and does not contain flakes etc.. (#23118) And yes this one test there actually depend on the default mounts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is indeed dirty and hacky. I need to get more familiar with the testing framework setup to improve this.

I noticed numerous tests, which were designed specifically for testing volume mounts, so, I didn't expect there will be some test, which implicitly test default ones. Probably the behavior from that test could be adjusted by loading the config as an app would do and manually converting it into chain of -v "/some:/some" -v "/other:/other", but I'm not sure if it worth doing or if it is better to keep the things as is for testing as they have proved to be working fine already.

Alternatively I could keep everything as is and try to add dedicated tests for the new API option checking that it will create no mounts. And if at later point the adjustment of default testing setting would be needed it can be done in a separate PR. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I find it important that we test defaults. Adding explicit machine mounts means we are no longer testing how most users use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this workaround. Also, added a dedicated test for this command line.

@l0rd
Copy link
Member

l0rd commented Jul 12, 2024

@l0rd my scenario is the system, where I reinstall (often with prune everything uninstall or sometimes restoring that system from snapshot) Podman releases rebuilt from main head often and I can't have mounts operational. It's very specific and can be mitigated with some sort of automation on my side.

Thank you @arixmkii. Given the rarity of the use case we should avoid a new option. But this PR fixes the issue with an empty list of volume (-v "" creates a broken machine). So it makes sense to merge it as soon as you have addressed @Luap99 comments.

I have tested it on macOS with libkrun and it worked well 👍

@arixmkii
Copy link
Contributor Author

arixmkii commented Jul 15, 2024

macOS machine test failed is legitimate. It seems that macOS mounts some additional paths for system purposes (I have no macOS hardware to check). I will disable new test on macOS.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
@arixmkii
Copy link
Contributor Author

Disabled test for both applehv and libkrun. Would appreciate if someone could share output of findmnt -t virtiofs from applehv and libkrun machines with default configuration to confirm my guess that there are additional active mounts to ones defined in standard config.

@Luap99
Copy link
Member

Luap99 commented Jul 17, 2024

@Luap99
Copy link
Member

Luap99 commented Jul 17, 2024

Ah I think the thing is that we mount rosetta payload via virtiofs on applehv thus you see the extra mount there.

@arixmkii
Copy link
Contributor Author

arixmkii commented Jul 17, 2024

@Luap99 Thank you! But, unfortunately, I don't need default ones, I need actual. I'm guessing that Rossetta binfmt is being mount as virtiofs from the host, but I can't prove it w/o testing. In this case there will be a virtiofs mount on macOS even, when no user mounts are set for VM.My current believe is that this is what lead to a test failure on macOS.

Update: I wrote this message before page refreshed. So, it is duplicate of the comment above.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM, I will put it on my list to fix the test to ensure they work with applehv/libkrun but that should not block the merge.

Copy link
Contributor

openshift-ci bot commented Jul 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arixmkii, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2024
@rhatdan
Copy link
Member

rhatdan commented Jul 21, 2024

/lgtm
thanks @arixmkii

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 003527f into containers:main Jul 21, 2024
87 checks passed
@arixmkii arixmkii deleted the disable-mounts branch July 26, 2024 10:50
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 25, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow disabling default mounts via podman machine init command
6 participants