fix: don't warn against virtualbox when minikube auto-selected it#22959
fix: don't warn against virtualbox when minikube auto-selected it#22959rafaelmfried wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rafaelmfried The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @rafaelmfried! |
|
Hi @rafaelmfried. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Can one of the admins verify this patch? |
When the user explicitly picks --driver=virtualbox, the warning steering them to a better driver is useful. But when minikube auto-selects virtualbox (because no other driver was viable on the host), the warning is misleading: minikube already considered the alternatives and rejected them. Thread the 'specified' flag from selectDriver through provisionWithDriver into node.Starter, and gate the existing warning on it. The retry path that swaps in an alternate driver after a failure is also treated as non-user-specified.
Extracts the warn-virtualbox condition into a pure function so the suppression logic added in the previous commit (no warning when minikube auto-selects virtualbox) can be exercised without spinning up a real cluster.
635a6bd to
721fe7d
Compare
|
/easycla |
Local validationReporting test results from my local macOS Sequoia (Apple Silicon) box. Targeted unit test``` === RUN TestShouldWarnVirtualBox The bug-fixing case is the second one (auto-selected virtualbox → suppress). Full unit test suiteRan `MINIKUBE_LDFLAGS="" TESTSUITE=unittest ./test.sh` covering `./cmd/...` and `./pkg/...` (~80 packages). All packages `ok`, no `FAIL`. `pkg/minikube/node` shown below for emphasis: ``` (Coverage is low for this package overall because it has no other tests yet — this PR adds the first one.) Note on local lintRunning `make test` (full suite including `make lint-ci`) on master without my changes already fails with a pre-existing govet warning in `pkg/drivers/parallels/parallels_darwin.go:425` (printf %d with a `*go-version.Version` arg). Not introduced by this PR; happy to file a separate cleanup PR if useful. End-to-end validation against a real virtualbox cluster on Linux is planned as a follow-up; the function-level test above covers the regression boundary. |
The issue is the text, not the warning. The purpose of the warning is to recommend a better driver when a user selects virtaulbox, since the driver has a lower priority. Lets start with an issue about this, and discuss what it the wanted behavior there. To it looks like "You have selected "virtualbox" driver, but there are better options !" is the problem. The user did not select the driver. It can make sense to show this warning: |
nirs
left a comment
There was a problem hiding this comment.
The table showing when the warning is wanted looks good, but the real fix is to move the warning to argument validation phase. This will automatically fix the issue by handling only the case of --driver virtualbox - before minikube selects the driver.
| useForce := viper.GetBool(force) | ||
|
|
||
| starter, err := provisionWithDriver(cmd, ds, existing, options) | ||
| starter, err := provisionWithDriver(cmd, ds, existing, specified, options) |
There was a problem hiding this comment.
This makes provision code more complicate, passing more options down. We could use options for this, but I think we to move the warning earlier - before we select the driver, or better into start_flags.go. The warning about selecting a driver belong to argument validation phase, which must be done before we actually start the node.
| // asked for it — auto-selected virtualbox means no other driver was viable, | ||
| // so suggesting alternatives is misleading. See #15456. | ||
| if starter.Cfg.Driver == driver.VirtualBox && starter.DriverSpecified && viper.GetBool(config.WantVirtualBoxDriverWarning) { | ||
| warnVirtualBox(options) |
There was a problem hiding this comment.
Move this warning to start_flags. This is not the place to warn about the driver.
|
Thanks for the careful review @nirs — the argument-validation framing makes sense, and you're right that pushing A few quick notes before I pivot, since the rework is non-trivial and I'd like to make sure we're aiming at the same target:
If B is the direction you want, I'll close this and open a fresh PR against Either way I'd rather not guess and end up with another PR rotting in |
|
While we wait for direction, I went ahead and prototyped @nirs's suggestion as a separate draft PR for side-by-side comparison: #22960. Same end-user behavior on the bug case in this issue, but with the warning living in argument-validation and a reworded message (drops the contradictory "You have selected …" opener). Either PR is mergeable; the other will be closed once we know which shape is preferred. No need to review #22960 in depth yet — it's there so the choice is concrete rather than hypothetical. |
The flag Unfortunately we don't have
I agree, this is the right place to warn about the user select argument. Also selecting a driver when we have an existing cluster does not make sense. If the cluster exists (stopped or started) there is nothing to select.
I suggested to remove the text about select augment to warn about better driver when the user did not select the driver. But since we the warning we have now is only for user selection, we can consider this change later. |
Fixes #15456
Problem
When minikube auto-selects the virtualbox driver (because no other driver was viable on the host), it still emits the steering-away-from-virtualbox warning:
This is contradictory: minikube has just told the user it picked virtualbox itself because the alternatives weren't viable, then immediately suggests using one of those alternatives.
Fix
selectDriveralready returns aspecified boolindicating whether the user explicitly chose the driver (via--driver,--vm-driver, or an existing persisted profile). This patch threads that flag throughprovisionWithDriverintonode.Starter(newDriverSpecifiedfield) and gates the warning on it.node start) → suppress (user already saw or opted out at cluster creation)Tests
New table-driven unit test
TestShouldWarnVirtualBoxinpkg/minikube/node/start_test.gocovers six combinations:The condition was extracted into a small pure function
shouldWarnVirtualBox(driverName, driverSpecified, wantWarning)so the suppression logic is testable without spinning up a real cluster.Manual validation
--driver=virtualbox--driver=virtualbox, opted outEnd-to-end validation against a real virtualbox cluster on Linux is planned as a follow-up in the PR comments once a host is available; the local function-level test covers the regression boundary.
Notes
DriverAutoSelectedonClusterConfig(which would touch the on-disk profile schema), it stays on the in-memorynode.Starterstruct, which is the only consumer of the flag.