Skip to content

Conversation

nirs
Copy link
Contributor

@nirs nirs commented Oct 2, 2025

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

@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 2, 2025
@k8s-ci-robot k8s-ci-robot requested review from medyagh and prezha October 2, 2025 18:15
@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 2, 2025
@nirs
Copy link
Contributor Author

nirs commented Oct 2, 2025

/cc @ComradeProgrammer
/cc @afbjorklund

@nirs
Copy link
Contributor Author

nirs commented Oct 2, 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 2, 2025
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.
@nirs nirs force-pushed the remove-viper-checks branch from 1a26ae8 to cf26111 Compare October 2, 2025 19:25
@afbjorklund afbjorklund removed their request for review October 2, 2025 19:26
Copy link
Member

@medyagh medyagh left a 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)

@medyagh
Copy link
Member

medyagh commented Oct 2, 2025

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

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

Test name Commit Details Required Rerun command
pull-minikube-integration cf26111 link true /test pull-minikube-integration

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) {
Copy link
Member

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.

Copy link
Contributor Author

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 {
Copy link
Contributor Author

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)
Copy link
Contributor Author

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:"-"`
Copy link
Contributor Author

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.

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21683 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 42.9s    │ 43.2s                  │
│ enable ingress │ 16.1s    │ 15.8s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 44.1s 43.4s 41.3s 43.5s 42.0s
Times for minikube (PR 21683) start: 42.0s 43.4s 43.0s 45.5s 42.2s

Times for minikube ingress: 15.9s 16.4s 16.3s 15.8s 15.9s
Times for minikube (PR 21683) ingress: 15.9s 15.9s 15.9s 15.4s 15.9s

docker driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21683 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 23.6s    │ 23.3s                  │
│ enable ingress │ 12.7s    │ 11.9s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube ingress: 12.7s 10.7s 12.7s 13.7s 13.7s
Times for minikube (PR 21683) ingress: 12.7s 11.7s 11.7s 10.7s 12.7s

Times for minikube start: 22.2s 24.3s 22.9s 25.6s 23.2s
Times for minikube (PR 21683) start: 22.5s 24.0s 23.6s 23.2s 23.2s

docker driver with containerd runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21683 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 20.7s    │ 20.9s                  │
│ enable ingress │ 21.0s    │ 20.2s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube (PR 21683) start: 22.9s 20.5s 21.9s 19.4s 19.9s
Times for minikube start: 20.0s 20.6s 21.6s 21.0s 20.2s

Times for minikube (PR 21683) ingress: 20.2s 20.2s 20.2s 20.2s 20.2s
Times for minikube ingress: 22.1s 20.2s 22.2s 20.2s 20.2s


package run

// Options are start options.
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

@nirs
Copy link
Contributor Author

nirs commented Oct 2, 2025

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"))

@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
Docker_Windows (2 failed) TestErrorSpam/setup(gopogh) Unknown
Docker_Windows (2 failed) TestFunctional/parallel/ImageCommands/ImageBuild(gopogh) Unknown
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/DashboardCmd(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/ServiceCmdConnect(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/PersistentVolumeClaim(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/ServiceCmd/DeployApp(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/ServiceCmd/HTTPS(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/ServiceCmd/Format(gopogh) 0.00% (chart)
Docker_Linux_docker_arm64 (7 failed) TestFunctional/parallel/ServiceCmd/URL(gopogh) 0.00% (chart)

Besides the following environments also have failed tests:

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

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/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.

move viper calls from packages into cmd to improve testability/resusablitily
4 participants