Skip to content

Commit

Permalink
Move exit.Message function so that we aren't exiting from a library
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Sep 30, 2020
1 parent da4833d commit 0a31bb6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand All @@ -135,9 +134,10 @@ func (d *Driver) Create() error {
t := time.Now()
glog.Infof("Starting extracting preloaded images to volume ...")
// 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 err := oci.ExtractTarballToVolume(d.NodeConfig.OCIBinary, download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, d.NodeConfig.ImageDigest); err != nil || true {
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 {
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/drivers/kic/oci/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0a31bb6

Please sign in to comment.