Skip to content
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

check if container is running after create #6924

Merged
merged 3 commits into from
Mar 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/util/retry"

"fmt"
"os/exec"
Expand Down Expand Up @@ -164,6 +165,23 @@ func CreateContainerNode(p CreateParams) error {
if err != nil {
return errors.Wrap(err, "create a kic node")
}

checkRunning := func() error {
s, err := ContainerStatus(p.OCIBinary, p.Name)
if err != nil {
return fmt.Errorf("temporary error checking status for %q : %v", p.Name, err)
}
if s != "running" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wdyt of having all possible states as constants? That way they can be reused later on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a good idea ! eventually we should have a container status with libmachine's state strcut I will create an issue for this and do it in a following up PR

return fmt.Errorf("temporary error created container %q is not running yet", p.Name)
}
return nil
}

// retry up to up 5 seconds to make sure the created container status is running.
if err = retry.Expo(checkRunning, 13*time.Millisecond, time.Second*5); err != nil {
glog.Warningf("The created container %q failed to report to be running in 5 seconds.", p.Name)
}

return nil
}

Expand Down