-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Remove viper from minikube and driver packages - part 1 #21683
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
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nirs 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 |
/cc @ComradeProgrammer |
b5925b8
to
1a26ae8
Compare
/ok-to-test |
1a26ae8
to
cf26111
Compare
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.
thank you for doing this ! this is gonna make minikube development much safer (and less suprises)
/ok-to-test |
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
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 should make to document this in the contributors guide
to never make a viper call outside CMD packages
@medyagh I remove all options, leaving only the infrastructure for adding options from the root command down to the driver. The next pull commits (or pull requests) will remove one viper option per commit to keep this easy to review and less likely to break. |
f46905b
to
d752111
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5e86397
to
239003c
Compare
16b6ee0
to
3e67c8e
Compare
cmd/minikube/cmd/root.go
Outdated
// commandOptions creates minikube runtime options from the command line flags. | ||
// Flags that must be handled outside of the cmd package must be added to | ||
// run.Options. | ||
func commandOptions() *run.Options { |
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 moved to cmd/flags.Options in later commit since this function does not work for sharing options in cmd/config.
3e67c8e
to
c7fcd88
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c7fcd88
to
9daa62a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Preparing for removal of viper usage outside of cmd/minikube/cmd package, add a minikube/run.Options type for keeping command line options from viper and passing to the library code. We need to pass options through many layers: cmd -> node -> machine -> registry -> driver The libmachine Driver API does not have a way to pass options, so we need to keep the options in the driver struct. drivers/common.CommonDriver keeps now Options field. This field is initialized when a driver is configured in the registry, registry.Configurator interface accept now *run.Options. Configuration happens only when the cluster is created. Driver.Options is not persisted so on the next start options contains the zero value with the defaults. The driver config function is called by the machine package, which is called by the node package, which called from the `start`, `node add`, and `node start` command. We go back from the driver config function and add the options argument until we reach the command code. In the cmd package, the options are created by new commandOptions() helper.
To remove viper.GetBool("interactive") call in vment.ValidateHelper() we need to pass the options to the function. It is called from minikube/registry/drvs/krunkit.status(). Update registry.StatusChecker to accept *run.Options, and relevant code so options pass from `start`, `node add`, and `node start` command pass options to the driver status() function. Unify the way we create the options in the cmd package. The options are always created in the runCommand function, so we have one call per command that need to pass options down to minikube. With this change we are ready to remove the first viper call.
This option keeps the value of the --interactive flag. We keep the negative value so the zero value of run.Options use the default value. This expose the default options for drivers, using zero value of drivers/common/CommandDriver.Options. This options should be handled in several places, this change only add the option.
We need to use pass options from cmd/config, but commandOptions() is a private function of the cmd package. We want to have single function for creating runtime options shared with the minikube packages, accessible from cmd and cmd/config (and other future packages). Add a new cmd/flags package keeping the flags names needed for creating run.Options and move commandOptions() to flag.Options(). The `interactive` constant was moved from form start_flags.go to the new package. We can move later all flags to the new package, but I started with the minimal change.
vment.ValidateHelper() accept now *run.Options and use options.NonInteractive to check if interaction is allowed. Update callers to pass options from the minikube command. Testing non-interactive mode: % sudo rm /etc/sudoers.d/vmnet-helper % sudo -k % out/minikube start -d krunkit --interactive=false 😄 minikube v1.37.0 on Darwin 26.0.1 (arm64) ✨ Using the krunkit (experimental) driver based on user configuration 🤷 Exiting due to PROVIDER_KRUNKIT_NOT_FOUND: The 'krunkit' provider was not found: exit status 1: sudo: a password is required 💡 Suggestion: Install and configure vment-helper 📘 Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/krunkit/ Testing interactive mode: % out/minikube start -d krunkit 😄 minikube v1.37.0 on Darwin 26.0.1 (arm64) 💡 Unable to run vmnet-helper without a password To configure vment-helper to run without a password, please check the documentation: https://github.com/nirs/vmnet-helper/#granting-permission-to-run-vmnet-helper Password: ✨ Using the krunkit (experimental) driver based on user configuration 👍 Starting "minikube" primary control-plane node in "minikube" cluster 🔥 Creating krunkit VM (CPUs=2, Memory=6144MB, Disk=20000MB) ... 🐳 Preparing Kubernetes v1.34.1 on Docker 28.4.0 ... 🔗 Configuring bridge CNI (Container Networking Interface) ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: default-storageclass, storage-provisioner 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
filewall.UnblockBootpd() accepts now *run.Options and use it to check if we can interact with the user. Update callers to pass options. To make this work for drivers, we initialize the driver CommonDriver with the options from the command line in the driver configure() functions for vfkit, qemu, and krunkit. Other drivers do not need this flag so they use the zero value with the defaults.
The notify helpers accept now *run.Options and use it to check if we can interact with the user. Modify callers to pass options using cmd/flags.Options().
9daa62a
to
ec1ad26
Compare
@nirs: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
kvm2 driver with docker runtime
Times for minikube start: 47.6s 45.4s 44.4s 45.0s 45.3s Times for minikube ingress: 16.3s 16.9s 15.8s 17.9s 15.9s docker driver with docker runtime
Times for minikube start: 24.7s 20.2s 25.9s 22.5s 23.1s Times for minikube ingress: 10.6s 10.6s 13.7s 10.6s 12.6s docker driver with containerd runtime
Times for minikube start: 19.7s 20.2s 23.9s 19.9s 20.5s Times for minikube ingress: 20.1s 20.1s 20.1s 50.1s 23.1s |
Here are the number of top 10 failed tests in each environments with lowest flake rate.
Besides the following environments also have failed tests:
To see the flake rates of all tests by environment, click here. |
Currently we use viper outside of cmd/minikube/cmd package in pkg/minikube/** and pkg/drivers/**. This introduce 2 issues:
This is the first part in removing viper calls outside of the cmd/minikube/cmd package.
Preparations
Removals
Known issues
Part-of #21670