From a67b5e1d84543c252024fcfb2f588f722542da2a Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Fri, 29 Jun 2018 01:56:15 +0200 Subject: [PATCH] Fix timing issue with etcd snapshot --- docker/docker.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker/docker.go b/docker/docker.go index 0e7c76246..874cb8893 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -10,6 +10,7 @@ import ( "io/ioutil" "os" "strings" + "time" "github.com/coreos/go-semver/semver" ref "github.com/docker/distribution/reference" @@ -24,6 +25,7 @@ import ( const ( DockerRegistryURL = "docker.io" + RestartTimeout = 30 ) var K8sDockerVersions = map[string][]string{ @@ -53,6 +55,14 @@ func DoRunContainer(ctx context.Context, dClient *client.Client, imageCfg *conta } // Check for upgrades if container.State.Running { + // check if container is in a restarting loop + if container.State.Restarting { + logrus.Debugf("[%s] Container [%s] is in a restarting loop [%s]", plane, containerName, hostname) + restartTimeoutDuration := RestartTimeout * time.Second + if err := dClient.ContainerRestart(ctx, container.ID, &restartTimeoutDuration); err != nil { + return fmt.Errorf("Failed to start [%s] container on host [%s]: %v", containerName, hostname, err) + } + } logrus.Debugf("[%s] Container [%s] is already running on host [%s]", plane, containerName, hostname) isUpgradable, err := IsContainerUpgradable(ctx, dClient, imageCfg, containerName, hostname, plane) if err != nil {