-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Remove all minikube dependencies from drivers #4933
Changes from 4 commits
05da539
812e815
3369ebc
d2ab336
5fcb676
b38e090
4a1e521
24fe0b4
80a5cab
2c9ab43
c5fb950
eda4d7a
efb9da6
3264f2e
b970b1c
be8b237
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,6 @@ import ( | |
hyperkit "github.com/moby/hyperkit/go" | ||
"github.com/pkg/errors" | ||
pkgdrivers "k8s.io/minikube/pkg/drivers" | ||
|
||
"k8s.io/minikube/pkg/minikube/constants" | ||
commonutil "k8s.io/minikube/pkg/util" | ||
) | ||
|
||
const ( | ||
|
@@ -52,6 +49,7 @@ const ( | |
permErr = "%s needs to run with elevated permissions. " + | ||
"Please run the following command, then try again: " + | ||
"sudo chown root:wheel %s && sudo chmod u+s %s" | ||
driverHyperkit = "hyperkit" | ||
) | ||
|
||
// Driver is the machine driver for Hyperkit | ||
|
@@ -77,7 +75,6 @@ func NewDriver(hostName, storePath string) *Driver { | |
SSHUser: "docker", | ||
}, | ||
CommonDriver: &pkgdrivers.CommonDriver{}, | ||
DiskSize: commonutil.CalculateSizeInMB(constants.DefaultDiskSize), | ||
} | ||
} | ||
|
||
|
@@ -121,7 +118,7 @@ func (d *Driver) Create() error { | |
|
||
// DriverName returns the name of the driver | ||
func (d *Driver) DriverName() string { | ||
return constants.DriverHyperkit | ||
return driverHyperkit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "hyperkit" |
||
} | ||
|
||
// GetSSHHostname returns hostname for use with ssh | ||
|
@@ -227,7 +224,7 @@ func (d *Driver) Start() error { | |
h.Memory = d.Memory | ||
h.UUID = d.UUID | ||
// This should stream logs from hyperkit, but doesn't seem to work. | ||
logger := golog.New(os.Stderr, constants.DriverHyperkit, golog.LstdFlags) | ||
logger := golog.New(os.Stderr, driverHyperkit, golog.LstdFlags) | ||
h.SetLogger(logger) | ||
|
||
if vsockPorts, err := d.extractVSockPorts(); err != nil { | ||
|
@@ -269,12 +266,24 @@ func (d *Driver) Start() error { | |
|
||
d.IPAddress, err = GetIPAddressByMACAddress(mac) | ||
if err != nil { | ||
return &commonutil.RetriableError{Err: err} | ||
return &TempError{err} | ||
} | ||
return nil | ||
} | ||
|
||
if err := commonutil.RetryAfter(30, getIP, 2*time.Second); err != nil { | ||
// Implement a retry loop without calling any minikube code | ||
for i := 0; i < 30; i++ { | ||
err = getIP() | ||
if err == nil { | ||
break | ||
} | ||
if _, ok := err.(*tempError); !ok { | ||
return err | ||
} | ||
time.Sleep(2) | ||
} | ||
|
||
if err != nil { | ||
return fmt.Errorf("IP address never found in dhcp leases file %v", err) | ||
} | ||
log.Debugf("IP: %s", d.IPAddress) | ||
|
@@ -294,6 +303,10 @@ func (d *Driver) Start() error { | |
return nil | ||
} | ||
|
||
type tempError struct { | ||
Err error | ||
} | ||
|
||
//recoverFromUncleanShutdown searches for an existing hyperkit.pid file in | ||
//the machine directory. If it can't find it, a clean shutdown is assumed. | ||
//If it finds the pid file, it checks for a running hyperkit process with that pid | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ const ( | |
VMNetDomain = "/Library/Preferences/SystemConfiguration/com.apple.vmnet" | ||
// SharedNetAddrKey is the key for the network address | ||
SharedNetAddrKey = "Shared_Net_Address" | ||
|
||
IPErrorMessage = "could not find an IP address for %s" | ||
) | ||
|
||
var ( | ||
|
@@ -78,7 +80,7 @@ func getIPAddressFromFile(mac, path string) (string, error) { | |
return dhcpEntry.IPAddress, nil | ||
} | ||
} | ||
return "", fmt.Errorf("could not find an IP address for %s", mac) | ||
return "", fmt.Errorf(IPErrorMessage, mac) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would prefer having the printf inline here |
||
} | ||
|
||
func parseDHCPdLeasesFile(file io.Reader) ([]DHCPEntry, error) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,6 @@ import ( | |
"syscall" | ||
"time" | ||
|
||
"k8s.io/minikube/pkg/minikube/config" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
"k8s.io/minikube/pkg/util" | ||
|
||
"github.com/docker/machine/libmachine/drivers" | ||
"github.com/docker/machine/libmachine/log" | ||
"github.com/docker/machine/libmachine/state" | ||
|
@@ -91,6 +87,7 @@ const ( | |
qemusystem = "qemu:///system" | ||
defaultPrivateNetworkName = "minikube-net" | ||
defaultNetworkName = "default" | ||
driverKvm2 = "kvm2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or just use the string ? |
||
) | ||
|
||
// NewDriver creates a new driver for a host | ||
|
@@ -102,14 +99,8 @@ func NewDriver(hostName, storePath string) *Driver { | |
SSHUser: "docker", | ||
}, | ||
CommonDriver: &pkgdrivers.CommonDriver{}, | ||
Boot2DockerURL: constants.DefaultISOURL, | ||
CPU: constants.DefaultCPUS, | ||
DiskSize: util.CalculateSizeInMB(constants.DefaultDiskSize), | ||
Memory: util.CalculateSizeInMB(constants.DefaultMemorySize), | ||
PrivateNetwork: defaultPrivateNetworkName, | ||
Network: defaultNetworkName, | ||
DiskPath: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), fmt.Sprintf("%s.rawdisk", config.GetMachineName())), | ||
ISO: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "boot2docker.iso"), | ||
ConnectionURI: qemusystem, | ||
} | ||
} | ||
|
@@ -224,7 +215,7 @@ func (d *Driver) GetSSHHostname() (string, error) { | |
|
||
// DriverName returns the name of the driver | ||
func (d *Driver) DriverName() string { | ||
return constants.DriverKvm2 | ||
return driverKvm2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "kvm2" |
||
} | ||
|
||
// Kill stops a host forcefully, including any containers that we are managing. | ||
|
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.
or just use the string?