Skip to content

Commit 1061a2a

Browse files
authored
Merge pull request kubernetes#6924 from medyagh/check_running
check if container is running after create
2 parents 1cb225f + a58a9f0 commit 1061a2a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/drivers/kic/oci/oci.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/pkg/errors"
3030
"k8s.io/minikube/pkg/minikube/constants"
3131
"k8s.io/minikube/pkg/minikube/localpath"
32+
"k8s.io/minikube/pkg/util/retry"
3233

3334
"fmt"
3435
"os/exec"
@@ -164,6 +165,23 @@ func CreateContainerNode(p CreateParams) error {
164165
if err != nil {
165166
return errors.Wrap(err, "create a kic node")
166167
}
168+
169+
checkRunning := func() error {
170+
s, err := ContainerStatus(p.OCIBinary, p.Name)
171+
if err != nil {
172+
return fmt.Errorf("temporary error checking status for %q : %v", p.Name, err)
173+
}
174+
if s != "running" {
175+
return fmt.Errorf("temporary error created container %q is not running yet", p.Name)
176+
}
177+
return nil
178+
}
179+
180+
// retry up to up 5 seconds to make sure the created container status is running.
181+
if err = retry.Expo(checkRunning, 13*time.Millisecond, time.Second*5); err != nil {
182+
glog.Warningf("The created container %q failed to report to be running in 5 seconds.", p.Name)
183+
}
184+
167185
return nil
168186
}
169187

0 commit comments

Comments
 (0)