-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Start removing viper calls in minikube #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 |
Pass --interactive, --download-only, and --delete-on-failure via new run.Options struct so minikube code can stop accessing the flags via viper. There are many more viper calls in the minikube package. Removing all of them requires adding mode options and modifying more code to accept options argument. To pass options to driver we keep Options in drivers.common.CommonDriver. Options are not persisted so un-marshalling drivers from config.json use the default options.
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 |
@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. |
} | ||
|
||
// startHostInternal starts a new minikube host using a VM or None | ||
func startHostInternal(api libmachine.API, cc *config.ClusterConfig, n *config.Node, delOnFail bool) (*host.Host, bool, error) { |
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.
how about keep the original signature here
func startHostInternal(api libmachine.API, cc *config.ClusterConfig, n *config.Node, delOnFail bool) (*host.Host, bool, error)
and just pass "options.DeleteOnFailure" to the caller func
hostInfo, preExists, err = startHostInternal(m, cfg, node, options.DelOnFailure)
its okay if do pass the full run.options if it is being passed down to another func, but otherwise lets just call the func with as Little information as it needs.
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 do pass the value to next function, see bellow.
time.Sleep(5 * time.Second) | ||
|
||
if delOnFail { | ||
if options.DeleteOnFailure { |
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 use options.DeleteOnFailure here...
} | ||
|
||
hostInfo, exists, err = machine.StartHost(api, cc, n) | ||
hostInfo, exists, err = machine.StartHost(api, cc, n, 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.
And pass it to the next function here
// CommonDriver is the common driver base class | ||
type CommonDriver struct{} | ||
type CommonDriver struct { | ||
Options run.Options `json:"-"` |
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.
Maybe we need to comment here why this flag is not persisted.
kvm2 driver with docker runtime
Times for minikube start: 44.1s 43.4s 41.3s 43.5s 42.0s Times for minikube ingress: 15.9s 16.4s 16.3s 15.8s 15.9s docker driver with docker runtime
Times for minikube ingress: 12.7s 10.7s 12.7s 13.7s 13.7s Times for minikube start: 22.2s 24.3s 22.9s 25.6s 23.2s docker driver with containerd runtime
Times for minikube (PR 21683) start: 22.9s 20.5s 21.9s 19.4s 19.9s Times for minikube (PR 21683) ingress: 20.2s 20.2s 20.2s 20.2s 20.2s |
|
||
package run | ||
|
||
// Options are start 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.
"start" is leftover from older name of the package. Need to update and explain that there are minikube commands 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.
Should we return *run.Options? With 3 fields it should be fine, but we have 23 files using viper for other options, so we will need to add many more options to this struct.
Other viper calls not handled in this PR: % git grep 'viper.' | grep pkg/minikube | grep -v _test.go | grep -v _mock.go | grep -v github.com/spf13/viper
pkg/minikube/assets/addons.go: if viper.IsSet(config.AddonImages) {
pkg/minikube/assets/addons.go: newImages := parseMapString(viper.GetString(config.AddonImages))
pkg/minikube/assets/addons.go: if viper.IsSet(config.AddonRegistries) {
pkg/minikube/assets/addons.go: newRegistries := parseMapString(viper.GetString(config.AddonRegistries))
pkg/minikube/assets/addons.go: if viper.IsSet(config.AddonImages) || viper.IsSet(config.AddonRegistries) {
pkg/minikube/assets/addons.go: return images, customRegistries, config.Write(viper.GetString(config.ProfileName), cc)
pkg/minikube/audit/audit.go: u := viper.GetString(config.UserFlag)
pkg/minikube/audit/audit.go: if viper.IsSet(config.MaxAuditEntries) {
pkg/minikube/audit/audit.go: maxEntries = viper.GetInt(config.MaxAuditEntries)
pkg/minikube/audit/audit.go: if viper.GetBool(config.SkipAuditFlag) {
pkg/minikube/audit/audit.go: return pflag.Arg(0) == "delete" && viper.GetBool("purge")
pkg/minikube/audit/row.go: p := viper.GetString(config.ProfileName)
pkg/minikube/cluster/mount.go: profile := viper.GetString("profile")
pkg/minikube/config/config.go: return viper.GetInt("nodes") > 1
pkg/minikube/config/config.go: return viper.GetBool("ha")
pkg/minikube/config/profile.go: return SaveProfile(viper.GetString(ProfileName), cfg)
pkg/minikube/config/profile.go: activeP := viper.GetString(ProfileName)
pkg/minikube/config/profile.go: activeP := viper.GetString(ProfileName)
pkg/minikube/detect/detect.go: p := viper.GetString("socket-vmnet-path")
pkg/minikube/detect/detect.go: p := viper.GetString("socket-vmnet-client-path")
pkg/minikube/download/preload.go: // TODO (#8166): Get rid of the need for this and viper at all
pkg/minikube/download/preload.go: if !driver.AllowsPreload(driverName) || !viper.GetBool("preload") && !force {
pkg/minikube/machine/start.go: if viper.GetBool("force") {
pkg/minikube/node/cache.go: if !viper.GetBool(cacheImages) {
pkg/minikube/node/cache.go: binariesURL := viper.GetString("binary-mirror")
pkg/minikube/node/cache.go: if !viper.GetBool(cacheImages) {
pkg/minikube/node/config.go: profile := viper.GetString("profile")
pkg/minikube/node/node.go: return n, config.SaveProfile(viper.GetString(config.ProfileName), &cc)
pkg/minikube/node/node.go: return config.SaveProfile(viper.GetString(config.ProfileName), cfg)
pkg/minikube/node/start.go: return nil, config.Write(viper.GetString(config.ProfileName), starter.Cfg)
pkg/minikube/node/start.go: bs, err = cluster.Bootstrapper(starter.MachineAPI, viper.GetString(cmdcfg.Bootstrapper), *starter.Cfg, starter.Runner)
pkg/minikube/node/start.go: pcpBs, err := cluster.ControlPlaneBootstrapper(starter.MachineAPI, starter.Cfg, viper.GetString(cmdcfg.Bootstrapper))
pkg/minikube/node/start.go: addonList := viper.GetStringSlice(config.AddonListFlag)
pkg/minikube/node/start.go: if viper.GetBool("force") {
pkg/minikube/node/start.go: if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) {
pkg/minikube/node/start.go: klog.Infof("Will wait %s for node %+v", viper.GetDuration(waitTimeout), starter.Node)
pkg/minikube/node/start.go: if err := bs.WaitForNode(*starter.Cfg, *starter.Node, viper.GetDuration(waitTimeout)); err != nil {
pkg/minikube/node/start.go: return nil, errors.Wrapf(err, "wait %s for node", viper.GetDuration(waitTimeout))
pkg/minikube/node/start.go: return kcs, config.Write(viper.GetString(config.ProfileName), starter.Cfg)
pkg/minikube/node/start.go: return true, config.Write(viper.GetString(config.ProfileName), starter.Cfg)
pkg/minikube/node/start.go: if err := config.SaveProfile(viper.GetString(config.ProfileName), cc); err != nil {
pkg/minikube/node/start.go: if viper.GetBool("force-systemd") {
pkg/minikube/node/start.go: bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)
pkg/minikube/node/start.go: if viper.GetBool("force") {
pkg/minikube/node/start.go: if viper.GetBool(config.WantNoneDriverWarning) {
pkg/minikube/notify/notify.go: if !viper.GetBool(config.WantUpdateNotification) {
pkg/minikube/notify/notify.go: return time.Since(lastUpdateTime).Hours() >= viper.GetFloat64(config.ReminderWaitPeriodInHours)
pkg/minikube/notify/notify.go: if !viper.GetBool(config.WantBetaUpdateNotification) {
pkg/minikube/reason/reason.go: // an error occurred when viper attempted to bind flags to configuration
pkg/minikube/registry/drvs/docker/docker.go: if !viper.GetBool("force") {
pkg/minikube/registry/drvs/qemu2/qemu2.go: qemuFirmware, err := qemuFirmwarePath(viper.GetString("qemu-firmware-path")) |
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. |
Pass --interactive, --download-only, and --delete-on-failure via new run.Options struct so minikube code can stop accessing the flags via viper.
There are many more viper calls in the minikube package. Removing all of them requires adding mode options and modifying more code to accept options argument.
To pass options to driver we keep Options in
drivers.common.CommonDriver. Options are not persisted so un-marshalling drivers from config.json use the default options.
Fixes #21670