Skip to content
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

Avoid provision.Detector when possible #7244

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions pkg/minikube/machine/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,24 @@ func fixHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*host.
return h, errors.Wrap(err, "Error loading existing host. Please try running [minikube delete], then run [minikube start] again.")
}

driverName := h.Driver.DriverName()

// check if need to re-run docker-env
maybeWarnAboutEvalEnv(cc.Driver, cc.Name)
maybeWarnAboutEvalEnv(driverName, cc.Name)

h, err = recreateIfNeeded(api, cc, n, h)
if err != nil {
return h, err
}

// Technically, we should only have to call provision if Docker has changed,
// but who can predict what shape the existing VM is in.
e := engineOptions(cc)
h.HostOptions.EngineOptions.Env = e.Env
err = provisionDockerMachine(h)
if err != nil {
return h, errors.Wrap(err, "provision")
// Avoid reprovisioning "none" driver because provision.Detect requires SSH
if !driver.BareMetal(h.Driver.DriverName()) {
e := engineOptions(cc)
h.HostOptions.EngineOptions.Env = e.Env
err = provisionDockerMachine(h)
if err != nil {
return h, errors.Wrap(err, "provision")
}
}

if driver.IsMock(h.DriverName) {
Expand All @@ -86,11 +89,11 @@ func fixHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*host.
}

if driver.BareMetal(h.Driver.DriverName()) {
glog.Infof("%s is local, skipping auth/time setup (requires ssh)", h.Driver.DriverName())
glog.Infof("%s is local, skipping auth/time setup (requires ssh)", driverName)
return h, nil
}

return h, ensureSyncedGuestClock(h, cc.Driver)
return h, ensureSyncedGuestClock(h, driverName)
}

func recreateIfNeeded(api libmachine.API, cc config.ClusterConfig, n config.Node, h *host.Host) (*host.Host, error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/minikube/machine/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package machine

import (
"io/ioutil"
"os/exec"

"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/provision"
"github.com/golang/glog"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/out"
)

Expand Down Expand Up @@ -80,18 +81,17 @@ func showLocalOsRelease() {
}

// logRemoteOsRelease shows systemd information about the current linux distribution, on the remote VM
func logRemoteOsRelease(drv drivers.Driver) {
provisioner, err := provision.DetectProvisioner(drv)
func logRemoteOsRelease(r command.Runner) {
rr, err := r.RunCmd(exec.Command("cat", "/etc/os-release"))
if err != nil {
glog.Errorf("DetectProvisioner: %v", err)
return
glog.Infof("remote release failed: %v", err)
}

osReleaseInfo, err := provisioner.GetOsReleaseInfo()
osReleaseInfo, err := provision.NewOsRelease(rr.Stdout.Bytes())
if err != nil {
glog.Errorf("GetOsReleaseInfo: %v", err)
glog.Errorf("NewOsRelease: %v", err)
return
}

glog.Infof("Provisioned with %s", osReleaseInfo.PrettyName)
glog.Infof("Remote host: %s", osReleaseInfo.PrettyName)
}
2 changes: 1 addition & 1 deletion pkg/minikube/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func postStartSetup(h *host.Host, mc config.ClusterConfig) error {
showLocalOsRelease()
}
if driver.IsVM(mc.Driver) {
logRemoteOsRelease(h.Driver)
logRemoteOsRelease(r)
}
return syncLocalAssets(r)
}
Expand Down