Move exit.Message function so that we aren't exiting from a library

pull/9316/head
Priya Wadhwa 2020-09-30 15:17:58 -04:00
parent da4833d80a
commit db23825bfc
4 changed files with 17 additions and 5 deletions

View File

@ -197,6 +197,9 @@ func runStart(cmd *cobra.Command, args []string) {
machine.MaybeDisplayAdvice(err, ds.Name)
if specified {
// If the user specified a driver, don't fallback to anything else
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
}
exit.Error(reason.GuestProvision, "error provisioning host", err)
} else {
success := false
@ -224,6 +227,9 @@ func runStart(cmd *cobra.Command, args []string) {
}
}
if !success {
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
}
exit.Error(reason.GuestProvision, "error provisioning host", err)
}
}
@ -248,6 +254,9 @@ func runStart(cmd *cobra.Command, args []string) {
stopProfile(existing.Name)
starter, err = provisionWithDriver(cmd, ds, existing)
if err != nil {
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
}
exit.Error(reason.GuestProvision, "error provisioning host", err)
}
}

View File

@ -37,8 +37,6 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/sysinit"
"k8s.io/minikube/pkg/util/retry"
)
@ -126,6 +124,7 @@ func (d *Driver) Create() error {
var waitForPreload sync.WaitGroup
waitForPreload.Add(1)
var pErr error
go func() {
defer waitForPreload.Done()
// If preload doesn't exist, don't bother extracting tarball to volume
@ -137,7 +136,8 @@ func (d *Driver) Create() error {
// Extract preloaded images to container
if err := oci.ExtractTarballToVolume(d.NodeConfig.OCIBinary, download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, d.NodeConfig.ImageDigest); err != nil {
if strings.Contains(err.Error(), "No space left on device") {
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
pErr = oci.ErrInsufficientDockerStorage
return
}
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
} else {
@ -154,7 +154,7 @@ func (d *Driver) Create() error {
}
waitForPreload.Wait()
return nil
return pErr
}
// prepareSSH will generate keys and copy to the container so minikube ssh works

View File

@ -45,6 +45,9 @@ var ErrExitedUnexpectedly = errors.New("container exited unexpectedly")
// ErrDaemonInfo is thrown when docker/podman info is failing or not responding
var ErrDaemonInfo = errors.New("daemon info not responding")
// ErrInsufficientDockerStorage is thrown when there is not more storage for docker
var ErrInsufficientDockerStorage = &FailFastError{errors.New("insufficient docker storage, no space left on device")}
// LogContainerDebug will print relevant docker/podman infos after a container fails
func LogContainerDebug(ociBin string, name string) string {
rr, err := containerInspect(ociBin, name)

View File

@ -383,7 +383,7 @@ func startHost(api libmachine.API, cc *config.ClusterConfig, n *config.Node, del
}
}
if _, ff := err.(*oci.FailFastError); ff {
if err, ff := errors.Cause(err).(*oci.FailFastError); ff {
glog.Infof("will skip retrying to create machine because error is not retriable: %v", err)
return host, exists, err
}