Skip to content

Commit d46decf

Browse files
authored
Merge pull request #4198 from tstromberg/libvirt-solutions
Add solution text for common kvm2 and VirtualBox problems
2 parents e0bf9a5 + 1fe716a commit d46decf

File tree

4 files changed

+147
-15
lines changed

4 files changed

+147
-15
lines changed

pkg/minikube/exit/exit.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package exit
2020
import (
2121
"fmt"
2222
"os"
23+
"runtime"
2324

2425
"github.com/golang/glog"
2526
"k8s.io/minikube/pkg/minikube/console"
@@ -59,7 +60,7 @@ func WithCode(code int, format string, a ...interface{}) {
5960

6061
// WithError outputs an error and exits.
6162
func WithError(msg string, err error) {
62-
p := problem.FromError(err)
63+
p := problem.FromError(err, runtime.GOOS)
6364
if p != nil {
6465
WithProblem(msg, p)
6566
}

pkg/minikube/problem/err_map.go

+63-9
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,49 @@ var vmProblems = map[string]match{
3636
Advice: "In some environments, this message is incorrect. Try 'minikube start --no-vtx-check'",
3737
Issues: []int{3900},
3838
},
39-
"VBOX_THIRD_PARTY": {
40-
Regexp: re(`The virtual machine * has terminated unexpectedly during startup with exit code 1`),
41-
Advice: "A third-party program may be interfering with VirtualBox. Try disabling any real-time antivirus software, reinstalling VirtualBox and rebooting.",
42-
Issues: []int{3910},
39+
"VBOX_VERR_VMX_NO_VMX": {
40+
Regexp: re(`VT-x is not available.*VERR_VMX_NO_VMX`),
41+
Advice: "Please check your BIOS, and ensure that you are running without HyperV or other nested virtualization that may interfere",
42+
Issues: []int{1994},
43+
},
44+
"VBOX_BLOCKED": {
45+
Regexp: re(`NS_ERROR_FAILURE.*0x80004005`),
46+
Advice: "Reinstall VirtualBox and verify that it is not blocked: System Preferences -> Security & Privacy -> General -> Some system software was blocked from loading",
47+
Issues: []int{4107},
48+
GOOS: "darwin",
49+
},
50+
"VBOX_DRV_NOT_LOADED": {
51+
Regexp: re(`The vboxdrv kernel module is not loaded`),
52+
Advice: "Run 'sudo modprobe vboxdrv' and reinstall VirtualBox if it fails.",
53+
Issues: []int{4043},
54+
},
55+
"VBOX_DEVICE_MISSING": {
56+
Regexp: re(`/dev/vboxdrv does not exist`),
57+
Advice: "Run 'sudo modprobe vboxdrv' and reinstall VirtualBox if it fails.",
58+
Issues: []int{3974},
59+
},
60+
"VBOX_HARDENING": {
61+
Regexp: re(`terminated unexpectedly.*VBoxHardening`),
62+
Advice: "Disable real-time anti-virus software, reboot, and reinstall VirtualBox if the problem continues.",
63+
Issues: []int{3859, 3910},
64+
URL: "https://forums.virtualbox.org/viewtopic.php?f=25&t=82106",
65+
GOOS: "windows",
66+
},
67+
"VBOX_HOST_ADAPTER": {
68+
Regexp: re(`The host-only adapter we just created is not visible`),
69+
Advice: "Reboot to complete VirtualBox installation, and verify that VirtualBox is not blocked by your system",
70+
Issues: []int{3614},
71+
URL: "https://stackoverflow.com/questions/52277019/how-to-fix-vm-issue-with-minikube-start",
72+
},
73+
"VBOX_BLOCKED_LOADING": {
74+
Regexp: re(`NS_ERROR_FAILURE.*0x80004005`),
75+
Advice: "Reinstall VirtualBox and verify that it is not blocked: System Preferences -> Security & Privacy -> General -> Some system software was blocked from loading",
76+
Issues: []int{4107},
77+
},
78+
"VBOX_KERNEL_MODULE_NOT_LOADED": {
79+
Regexp: re(`The vboxdrv kernel module is not loaded`),
80+
Advice: "Run 'sudo modprobe vboxdrv' and reinstall VirtualBox if it fails.",
81+
Issues: []int{4043},
4382
},
4483
"KVM2_NOT_FOUND": {
4584
Regexp: re(`Driver "kvm2" not found. Do you have the plugin binary .* accessible in your PATH`),
@@ -51,16 +90,17 @@ var vmProblems = map[string]match{
5190
Advice: "The KVM driver is unable to resurrect this old VM. Please run `minikube delete` to delete it and try again.",
5291
Issues: []int{3901, 3566, 3434},
5392
},
93+
"KVM2_NETWORK_DEFINE_XML": {
94+
Regexp: re(`not supported by the connection driver: virNetworkDefineXML`),
95+
Advice: "Rebuild libvirt with virt-network support",
96+
URL: "https://forums.gentoo.org/viewtopic-t-981692-start-0.html",
97+
Issues: []int{4195},
98+
},
5499
"VM_DOES_NOT_EXIST": {
55100
Regexp: re(`Error getting state for host: machine does not exist`),
56101
Advice: "Your system no longer knows about the VM previously created by minikube. Run 'minikube delete' to reset your local state.",
57102
Issues: []int{3864},
58103
},
59-
"VM_IP_NOT_FOUND": {
60-
Regexp: re(`Error getting ssh host name for driver: IP not found`),
61-
Advice: "The minikube VM is offline. Please run 'minikube start' to start it again.",
62-
Issues: []int{3849, 3648},
63-
},
64104
"VM_BOOT_FAILED_HYPERV_ENABLED": {
65105
Regexp: re(`VirtualBox won't boot a 64bits VM when Hyper-V is activated`),
66106
Advice: "Disable Hyper-V when you want to run VirtualBox to boot the VM",
@@ -156,3 +196,17 @@ var osProblems = map[string]match{
156196
Issues: []int{1574},
157197
},
158198
}
199+
200+
// stateProblems are issues relating to local state
201+
var stateProblems = map[string]match{
202+
"MACHINE_DOES_NOT_EXST": {
203+
Regexp: re(`Error getting state for host: machine does not exist`),
204+
Advice: "Run 'minikube delete' to delete the stale VM",
205+
Issues: []int{3864},
206+
},
207+
"IP_NOT_FOUND": {
208+
Regexp: re(`Error getting ssh host name for driver: IP not found`),
209+
Advice: "The minikube VM is offline. Please run 'minikube start' to start it again.",
210+
Issues: []int{3849, 3648},
211+
},
212+
}

pkg/minikube/problem/problem.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ const issueBase = "https://github.com/kubernetes/minikube/issues"
2727

2828
// Problem represents a known problem in minikube.
2929
type Problem struct {
30-
ID string
31-
Err error
30+
// ID is an arbitrary unique and stable string describing this issue
31+
ID string
32+
// Err is the original error
33+
Err error
34+
// Advice is actionable text that the user should follow
3235
Advice string
33-
URL string
36+
// URL is a reference URL for more information
37+
URL string
38+
// Issues are a list of related issues to this problem
3439
Issues []int
3540
}
3641

@@ -40,6 +45,8 @@ type match struct {
4045
Advice string
4146
URL string
4247
Issues []int
48+
// GOOS is what platforms this problem may be specific to, when disambiguation is necessary.
49+
GOOS string
4350
}
4451

4552
// Display problem metadata to the console
@@ -62,16 +69,20 @@ func (p *Problem) Display() {
6269
}
6370
}
6471

65-
// FromError returns a known problem from an error.
66-
func FromError(err error) *Problem {
72+
// FromError returns a known problem from an error on an OS
73+
func FromError(err error, os string) *Problem {
6774
maps := []map[string]match{
6875
osProblems,
6976
vmProblems,
7077
netProblems,
7178
deployProblems,
79+
stateProblems,
7280
}
7381
for _, m := range maps {
7482
for k, v := range m {
83+
if v.GOOS != "" && v.GOOS != os {
84+
continue
85+
}
7586
if v.Regexp.MatchString(err.Error()) {
7687
return &Problem{
7788
Err: err,

pkg/minikube/problem/problem_test.go

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package problem
18+
19+
import (
20+
"fmt"
21+
"testing"
22+
)
23+
24+
func TestFromError(t *testing.T) {
25+
var tests = []struct {
26+
issue int
27+
os string
28+
want string
29+
err string
30+
}{
31+
{0, "", "", "this is just a lame error message with no matches."},
32+
{3614, "", "VBOX_HOST_ADAPTER", "Error starting host: Error starting stopped host: Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is is supposed to fix this issue"},
33+
{3784, "", "VBOX_NOT_FOUND", "create: precreate: VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"},
34+
{3849, "", "IP_NOT_FOUND", "bootstrapper: Error creating new ssh host from driver: Error getting ssh host name for driver: IP not found"},
35+
{3859, "windows", "VBOX_HARDENING", `Unable to start VM: create: creating: Unable to start the VM: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm minikube --type headless failed:
36+
VBoxManage.exe: error: The virtual machine 'minikube' has terminated unexpectedly during startup with exit code -1073741819 (0xc0000005). More details may be available in 'C:\Users\pabitra_b.minikube\machines\minikube\minikube\Logs\VBoxHardening.log'
37+
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component MachineWrap, interface IMachine`},
38+
{3922, "", "ISO_DOWNLOAD_FAILED", `unable to cache ISO: https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: failed to download: failed to download to temp file: download failed: 5 error(s) occurred:
39+
* Temporary download error: Get https://storage.googleapis.com/minikube/iso/minikube-v0.35.0.iso: dial tcp 216.58.207.144:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.`},
40+
{4107, "darwin", "VBOX_BLOCKED", "Result Code: NS_ERROR_FAILURE (0x80004005)"},
41+
}
42+
for _, tc := range tests {
43+
t.Run(tc.want, func(t *testing.T) {
44+
got := FromError(fmt.Errorf(tc.err), tc.os)
45+
if got == nil {
46+
if tc.want != "" {
47+
t.Errorf("FromError(%q)=nil, want %s", tc.err, tc.want)
48+
}
49+
return
50+
}
51+
if got.ID != tc.want {
52+
t.Errorf("FromError(%q)=%s, want %s", tc.err, got.ID, tc.want)
53+
}
54+
55+
found := false
56+
for _, i := range got.Issues {
57+
if i == tc.issue {
58+
found = true
59+
}
60+
}
61+
if !found {
62+
t.Errorf("Issue %d is not listed in %+v", tc.issue, got.Issues)
63+
}
64+
})
65+
}
66+
}

0 commit comments

Comments
 (0)