-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Lower priority for NeedsSudo drivers when no sudo available (#21633) #21687
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: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: henry3260 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @henry3260. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Can one of the admins verify this patch? |
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.
This change is wrong in many ways:
- The idea to change the priority based on sudo requirement is wrong
- The check if sudo is available is wrong
- The information about which drivers requires sudo are mostly wrong
In general almost anything worth using requires sudo , and we should document the requirements. We should not change driver priority based on sudo requirements for setting up the system for the driver.
if !HasSudo() { | ||
for i := range options { | ||
if options[i].NeedsSudo { | ||
options[i].Priority = registry.Discouraged |
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.
We must not do this. Driver priority must not change based on sudo availability.
We can add more info on the driver status, but the priority must not change.
Default: d.Default, | ||
Priority: d.Priority, | ||
State: s, | ||
NeedsSudo: d.NeedsSudo, |
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.
This is problematic since this info is dynamic. For example vfkit does not need sudo with the default network (nat), but need sudo for setup with vmnet-shared network. This should be done in the driver documentation and not here.
func realHasSudo() bool { | ||
err := exec.Command("sudo", "-n", "true").Run() | ||
return err == nil | ||
} |
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.
This is incorrect check. Nobody configures a system so you can run any command as root without a password. This configuration is use only in throwaway systems like CI VM that is deleted after the CI run, or inside minikube VM where you are not expected to modify the host.
Default: true, | ||
Priority: registry.HighlyPreferred, | ||
// Docker driver does not require sudo | ||
NeedsSudo: false, |
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.
You must have sudo to install docker on Linux or add your self to docker group. This is same as kvm.
Default: true, | ||
Priority: registry.Deprecated, | ||
// Hyperkit driver requires sudo | ||
NeedsSudo: true, |
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.
Minikube has code to configure hyperkit to run without a password, but hyperkit is deprecated so it is not interesting to add this info.
Default: true, | ||
Priority: registry.Preferred, | ||
// KVM2 driver does not require sudo | ||
NeedsSudo: false, |
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.
Requires sudo to install libvirt and add yourself to the libvirt group.
Default: true, | ||
Priority: priority, | ||
// Podman driver may require sudo (on linux) | ||
NeedsSudo: true, |
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.
This depends on the os:
- Linux: requires sudo to install podman. Using rootless mode by default so no need to configure special group
- macOS: does not require sudo to install and run podman (using vfkit and gvproxy)
The minikube driver may have limitations and issues with using podman, it is not not well maintained.
Default: true, | ||
Priority: priority, | ||
// QEMU2 driver does not require sudo | ||
NeedsSudo: false, |
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.
Wrong, qemu can be installed via brew, but to use socket_vment (e.g to support multiple clusters accessing each other, or multi-node clusters), you need root - same as vmnet-helper.
This also depends on the system:
- Linux: sudo required to install qemu
- macOS: sudo not required to install qemu (e.g. brew install qemu)
Priority: registry.Discouraged, | ||
Init: func() drivers.Driver { return ssh.NewDriver(ssh.Config{}) }, | ||
// SSH driver does not require sudo | ||
NeedsSudo: false, |
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.
I think you will need sudo on the host you connect to.
Default: true, | ||
Priority: priority, | ||
// VFKit driver requires sudo | ||
NeedsSudo: true, |
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.
sudo required only for the initial setup to install vment-helper.
Fixes #21633
What this PR does
When sudo is not available on the host, drivers that require sudo (
NeedsSudo = true
) will have their priority lowered.Drivers that do not require sudo remain unaffected. This ensures the
Available()
function returns a properly prioritized driver list depending on the environment.How I tested