Skip to content

Conversation

@nirs
Copy link
Contributor

@nirs nirs commented Oct 24, 2025

This is the second part, removing more viper calls outside of cmd and replacing some viper calls that use a string instead of the constant.

profile

  • viper.GetString("profile")
  • viper.GetString(config.ProfileName)
  • viper.GetString(ProfileName)
  • viper.Set("profile", ...)
  • viper.Set(config.ProfileName, ...)
  • viper.Set(ProfileName, ...)

force

  • viper.GetBool(force) outside of cmd package
  • viper.GetBool("force") in cmd package

Remaning viper calls in pkg

viper.Get*

% git grep viper.Get pkg        
pkg/addons/validations.go:      addonList := viper.GetStringSlice(config.AddonListFlag)
pkg/minikube/assets/addons.go:          newImages := parseMapString(viper.GetString(config.AddonImages))
pkg/minikube/assets/addons.go:          newRegistries := parseMapString(viper.GetString(config.AddonRegistries))
pkg/minikube/audit/audit.go:    u := viper.GetString(config.UserFlag)
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/config/config.go:  return viper.GetInt("nodes") > 1
pkg/minikube/config/config.go:  return viper.GetBool("ha")
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:       if !driver.AllowsPreload(driverName) || !viper.GetBool("preload") && !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/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 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:     if viper.GetBool("force-systemd") {
pkg/minikube/node/start.go:     deleteOnFailure := viper.GetBool("delete-on-failure")
pkg/minikube/node/start.go:     bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)
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/registry/drvs/qemu2/qemu2.go:      qemuFirmware, err := qemuFirmwarePath(viper.GetString("qemu-firmware-path"))
pkg/provision/buildroot.go:             viper.GetString(config.ProfileName),
pkg/provision/ubuntu.go:                        viper.GetString(config.ProfileName),

viper.Set

% git grep viper.Set pkg
pkg/minikube/assets/addons_test.go:     viper.Set(name, fmt.Sprintf("%s=%s", k, v))
pkg/minikube/audit/audit_test.go:                       viper.Set(config.UserFlag, test.userFlag)
pkg/minikube/audit/audit_test.go:               viper.Set(config.MaxAuditEntries, 3)
pkg/minikube/notify/notify_test.go:     viper.Set(config.WantUpdateNotification, false)
pkg/minikube/notify/notify_test.go:     viper.Set(config.WantUpdateNotification, true)
pkg/minikube/notify/notify_test.go:     viper.Set(config.ReminderWaitPeriodInHours, 24)
pkg/minikube/notify/notify_test.go:     viper.Set("interactive", true)
pkg/minikube/notify/notify_test.go:     viper.Set(config.WantUpdateNotification, true)
pkg/minikube/notify/notify_test.go:     viper.Set(config.WantBetaUpdateNotification, false)
pkg/minikube/notify/notify_test.go:     viper.Set(config.WantBetaUpdateNotification, true)
pkg/minikube/notify/notify_test.go:     viper.Set(config.ReminderWaitPeriodInHours, 24)
pkg/minikube/notify/notify_test.go:                     viper.Set(config.WantUpdateNotification, tt.wantUpdateNotification)
pkg/minikube/notify/notify_test.go:                     viper.Set(config.WantBetaUpdateNotification, tt.wantBetaUpdateNotification)

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nirs
Once this PR has been reviewed and has the lgtm label, please assign spowelljr 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 24, 2025
@nirs nirs changed the title Remove viper checks part2 Remove viper calls outside of cmd part2 Oct 24, 2025
@nirs nirs changed the title Remove viper calls outside of cmd part2 Remove viper calls outside of cmd - part2 Oct 24, 2025
@nirs
Copy link
Contributor Author

nirs commented Oct 24, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Oct 24, 2025
@k8s-ci-robot
Copy link
Contributor

@nirs: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
integration-none-docker-linux-x86-64 af05322 link true /test integration-none-docker-linux-x86-64
integration-docker-crio-linux-x86-64 af05322 link true /test integration-docker-crio-linux-x86-64
integration-docker-docker-linux-x86-64 af05322 link true /test integration-docker-docker-linux-x86-64
integration-kvm-containerd-linux-x86-64 af05322 link true /test integration-kvm-containerd-linux-x86-64
integration-docker-containerd-linux-x86-64 af05322 link true /test integration-docker-containerd-linux-x86-64
integration-kvm-crio-linux-x86-64 af05322 link true /test integration-kvm-crio-linux-x86-64
integration-kvm-docker-linux-x86-64 af05322 link true /test integration-kvm-docker-linux-x86-64

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.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@nirs nirs force-pushed the remove-viper-checks-part2 branch from af05322 to d4c33ed Compare October 25, 2025 18:59
@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

nirs added 2 commits October 27, 2025 23:00
Add run.CommandOptions.ProfileName and use it to replace most of the
following calls:

- viper.GetString("profile")
- viper.GetString(config.ProfileName)
- viper.GetString(ProfileName)
- viper.Set("profile", ...)
- viper.Set(config.ProfileName, ...)
- viper.Set(ProfileName, ...)

The ProfileName constant is in minikube/config package, so we use the
existing constants instead of adding cmd/flags.ProfileName.

This is change is little bit bigger because the existing code was messy,
the tests mocks were broken, and one test was wrong. I should probably
split this change to smaller commits.

The minikube/provision package is still using
viper.GetString(config.ProfileName). I could not find a way to remove
this usage because libmachine API does not allow passing the options.
Add run.CommandOptions.Force option and use it to replace calls to
viper.GetBool("force") outside the cmd package, and call to
viper.GetBool(force) in the cmd package.
@nirs nirs force-pushed the remove-viper-checks-part2 branch from d4c33ed to 0500345 Compare October 27, 2025 21:00
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 27, 2025
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21790 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 41.1s    │ 41.4s                  │
│ enable ingress │ 25.6s    │ 17.4s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube (PR 21790) start: 41.1s 42.0s 42.0s 39.3s 42.7s
Times for minikube start: 44.1s 39.9s 40.0s 41.0s 40.5s

Times for minikube ingress: 44.7s 16.8s 15.8s 19.8s 30.8s
Times for minikube (PR 21790) ingress: 19.7s 15.8s 15.8s 19.7s 15.8s

docker driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21790 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 22.9s    │ 23.9s                  │
│ enable ingress │ 13.8s    │ 12.6s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 23.3s 23.1s 22.2s 22.8s 23.0s
Times for minikube (PR 21790) start: 24.2s 23.6s 22.4s 24.5s 24.7s

Times for minikube ingress: 12.7s 10.6s 14.6s 13.6s 17.6s
Times for minikube (PR 21790) ingress: 10.6s 10.7s 12.6s 16.6s 12.6s

docker driver with containerd runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21790 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 20.7s    │ 21.7s                  │
│ enable ingress │ 26.5s    │ 29.9s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 22.1s 19.9s 19.9s 20.5s 21.3s
Times for minikube (PR 21790) start: 19.3s 24.2s 19.6s 24.2s 21.0s

Times for minikube (PR 21790) ingress: 25.1s 37.1s 22.1s 23.1s 42.1s
Times for minikube ingress: 22.1s 23.1s 23.1s 42.1s 22.1s

@minikube-pr-bot
Copy link

Here are the number of top 10 failed tests in each environments with lowest flake rate.

Environment Test Name Flake Rate
KVM_Linux_crio (5 failed) TestFunctional/parallel/ImageCommands/ImageRemove(gopogh) 2.50% (chart)
Docker_Linux_containerd_arm64 (1 failed) TestScheduledStopUnix(gopogh) 9.80% (chart)

Besides the following environments also have failed tests:

  • Docker_Linux_crio: 37 failed (gopogh)

  • Docker_Linux_crio_arm64: 36 failed (gopogh)

To see the flake rates of all tests by environment, click here.

if d.BaseDriver.IPAddress != "" {
return d.BaseDriver.IPAddress, nil
if d.IPAddress != "" {
return d.IPAddress, nil
Copy link
Member

Choose a reason for hiding this comment

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

are these lints unrelated to the PR ?

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 is not required for this change, cleaned up while reading this code. I'll split these changes to separate commit or defer them to later since we probably have more instances of this.

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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants