-
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
Various fixes for the none driver #4778
Changes from all commits
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 |
---|---|---|
|
@@ -29,6 +29,7 @@ import ( | |
"time" | ||
|
||
"github.com/docker/machine/libmachine" | ||
"github.com/docker/machine/libmachine/drivers" | ||
"github.com/docker/machine/libmachine/engine" | ||
"github.com/docker/machine/libmachine/host" | ||
"github.com/docker/machine/libmachine/mcnerror" | ||
|
@@ -116,15 +117,24 @@ func StartHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) | |
return nil, errors.Wrap(err, "Error getting state for host") | ||
} | ||
|
||
if s == state.Running { | ||
console.OutStyle(console.Running, "Re-using the currently running %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName()) | ||
} else { | ||
console.OutStyle(console.Restarting, "Restarting existing %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName()) | ||
if err := h.Driver.Start(); err != nil { | ||
return nil, errors.Wrap(err, "start") | ||
if config.VMDriver != constants.DriverNone { | ||
if s == state.Running { | ||
console.OutStyle(console.Running, "Re-using the currently running %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName()) | ||
} else { | ||
console.OutStyle(console.Restarting, "Restarting existing %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName()) | ||
if err := h.Driver.Start(); err != nil { | ||
return nil, errors.Wrap(err, "start") | ||
} | ||
if err := api.Save(h); err != nil { | ||
return nil, errors.Wrap(err, "save") | ||
} | ||
|
||
} | ||
if err := api.Save(h); err != nil { | ||
return nil, errors.Wrap(err, "save") | ||
} else { | ||
if s == state.Running { | ||
console.OutStyle(console.Running, "Re-using the currently running %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName()) | ||
} else { | ||
exit.WithCode(exit.Unavailable, "Unable to reach %s VM for %q", h.Driver.DriverName(), cfg.GetMachineName()) | ||
} | ||
} | ||
|
||
|
@@ -149,6 +159,7 @@ func configureHost(h *host.Host, e *engine.Options) error { | |
if err != nil { | ||
return errors.Wrap(err, "detecting provisioner") | ||
} | ||
glog.Infof("Provisioning with %s...", provisioner.String()) | ||
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil { | ||
return errors.Wrap(err, "provision") | ||
} | ||
|
@@ -231,18 +242,20 @@ func trySSHPowerOff(h *host.Host) { | |
} | ||
|
||
// StopHost stops the host VM, saving state to disk. | ||
func StopHost(api libmachine.API) error { | ||
func StopHost(api libmachine.API, config cfg.MachineConfig) error { | ||
host, err := api.Load(cfg.GetMachineName()) | ||
if err != nil { | ||
return errors.Wrapf(err, "load") | ||
} | ||
console.OutStyle(console.Stopping, "Stopping %q in %s ...", cfg.GetMachineName(), host.DriverName) | ||
if err := host.Stop(); err != nil { | ||
alreadyInStateError, ok := err.(mcnerror.ErrHostAlreadyInState) | ||
if ok && alreadyInStateError.State == state.Stopped { | ||
return nil | ||
if config.VMDriver != constants.DriverNone { | ||
console.OutStyle(console.Stopping, "Stopping %q in %s ...", cfg.GetMachineName(), host.DriverName) | ||
if err := host.Stop(); err != nil { | ||
alreadyInStateError, ok := err.(mcnerror.ErrHostAlreadyInState) | ||
if ok && alreadyInStateError.State == state.Stopped { | ||
return nil | ||
} | ||
return &util.RetriableError{Err: errors.Wrapf(err, "Stop: %s", cfg.GetMachineName())} | ||
} | ||
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. If "stop" is unsupported by none, I think StopHost should return an unsupported error instead of nothing. 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. Well, StopHost is unsupported - but we should try to stop Kubernetes. Just TBD. Maybe I should add a stopKubernetes() function, similar to our uninstallKubernetes() And just make it empty or log something friendly... The problem is described in that other issue linked. |
||
return &util.RetriableError{Err: errors.Wrapf(err, "Stop: %s", cfg.GetMachineName())} | ||
} | ||
return nil | ||
} | ||
|
@@ -314,6 +327,7 @@ func engineOptions(config cfg.MachineConfig) *engine.Options { | |
InsecureRegistry: append([]string{pkgutil.DefaultServiceCIDR}, config.InsecureRegistry...), | ||
RegistryMirror: config.RegistryMirror, | ||
ArbitraryFlags: config.DockerOpt, | ||
InstallURL: drivers.DefaultEngineInstallURL, | ||
} | ||
return &o | ||
} | ||
|
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.
Should this say VM?
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.
Most people should be running
none
on a dedicated VM, but yeah - we normally use "VM" as a term for the host, in the case of "none" or "generic" or "docker" that might not actually be true.Normally it's called a machine, as in "something runs docker".