Skip to content

Commit db23825

Browse files
author
Priya Wadhwa
committed
Move exit.Message function so that we aren't exiting from a library
1 parent da4833d commit db23825

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Diff for: cmd/minikube/cmd/start.go

+9
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ func runStart(cmd *cobra.Command, args []string) {
197197
machine.MaybeDisplayAdvice(err, ds.Name)
198198
if specified {
199199
// If the user specified a driver, don't fallback to anything else
200+
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
201+
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
202+
}
200203
exit.Error(reason.GuestProvision, "error provisioning host", err)
201204
} else {
202205
success := false
@@ -224,6 +227,9 @@ func runStart(cmd *cobra.Command, args []string) {
224227
}
225228
}
226229
if !success {
230+
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
231+
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
232+
}
227233
exit.Error(reason.GuestProvision, "error provisioning host", err)
228234
}
229235
}
@@ -248,6 +254,9 @@ func runStart(cmd *cobra.Command, args []string) {
248254
stopProfile(existing.Name)
249255
starter, err = provisionWithDriver(cmd, ds, existing)
250256
if err != nil {
257+
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
258+
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
259+
}
251260
exit.Error(reason.GuestProvision, "error provisioning host", err)
252261
}
253262
}

Diff for: pkg/drivers/kic/kic.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ import (
3737
"k8s.io/minikube/pkg/minikube/constants"
3838
"k8s.io/minikube/pkg/minikube/cruntime"
3939
"k8s.io/minikube/pkg/minikube/download"
40-
"k8s.io/minikube/pkg/minikube/exit"
41-
"k8s.io/minikube/pkg/minikube/reason"
4240
"k8s.io/minikube/pkg/minikube/sysinit"
4341
"k8s.io/minikube/pkg/util/retry"
4442
)
@@ -126,6 +124,7 @@ func (d *Driver) Create() error {
126124

127125
var waitForPreload sync.WaitGroup
128126
waitForPreload.Add(1)
127+
var pErr error
129128
go func() {
130129
defer waitForPreload.Done()
131130
// If preload doesn't exist, don't bother extracting tarball to volume
@@ -137,7 +136,8 @@ func (d *Driver) Create() error {
137136
// Extract preloaded images to container
138137
if err := oci.ExtractTarballToVolume(d.NodeConfig.OCIBinary, download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, d.NodeConfig.ImageDigest); err != nil {
139138
if strings.Contains(err.Error(), "No space left on device") {
140-
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
139+
pErr = oci.ErrInsufficientDockerStorage
140+
return
141141
}
142142
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
143143
} else {
@@ -154,7 +154,7 @@ func (d *Driver) Create() error {
154154
}
155155

156156
waitForPreload.Wait()
157-
return nil
157+
return pErr
158158
}
159159

160160
// prepareSSH will generate keys and copy to the container so minikube ssh works

Diff for: pkg/drivers/kic/oci/errors.go

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ var ErrExitedUnexpectedly = errors.New("container exited unexpectedly")
4545
// ErrDaemonInfo is thrown when docker/podman info is failing or not responding
4646
var ErrDaemonInfo = errors.New("daemon info not responding")
4747

48+
// ErrInsufficientDockerStorage is thrown when there is not more storage for docker
49+
var ErrInsufficientDockerStorage = &FailFastError{errors.New("insufficient docker storage, no space left on device")}
50+
4851
// LogContainerDebug will print relevant docker/podman infos after a container fails
4952
func LogContainerDebug(ociBin string, name string) string {
5053
rr, err := containerInspect(ociBin, name)

Diff for: pkg/minikube/node/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func startHost(api libmachine.API, cc *config.ClusterConfig, n *config.Node, del
383383
}
384384
}
385385

386-
if _, ff := err.(*oci.FailFastError); ff {
386+
if err, ff := errors.Cause(err).(*oci.FailFastError); ff {
387387
glog.Infof("will skip retrying to create machine because error is not retriable: %v", err)
388388
return host, exists, err
389389
}

0 commit comments

Comments
 (0)