Skip to content

Conversation

henry3260
Copy link

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

  • Manually verified that a "NeedsSudo" driver gets a lower priority when sudo is unavailable.
  • Existing unit tests for driver registration and availability remain unaffected.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 3, 2025
@k8s-ci-robot k8s-ci-robot requested a review from prezha October 3, 2025 12:50
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: henry3260
Once this PR has been reviewed and has the lgtm label, please assign comradeprogrammer for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 3, 2025
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 3, 2025
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Contributor

@nirs nirs left a 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
Copy link
Contributor

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,
Copy link
Contributor

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
}
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if we have Sudo Permission, if not Lower The priority of the drivers that Need Sudo
4 participants