1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-23 12:28:15 +00:00

Fix timing issue with etcd snapshot

This commit is contained in:
galal-hussein
2018-06-29 01:56:15 +02:00
committed by Alena Prokharchyk
parent 8a52e0d8dc
commit a67b5e1d84

View File

@@ -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 {