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

Able to include and extract state file in snapshot

This commit is contained in:
Sebastiaan van Steenis
2020-03-30 21:16:47 +02:00
parent e2b5828e5b
commit 9bca29befb
8 changed files with 161 additions and 10 deletions

View File

@@ -483,14 +483,24 @@ func WaitForContainer(ctx context.Context, dClient *client.Client, hostname stri
return 1, fmt.Errorf("Could not inspect container [%s] on host [%s]: %s", containerName, hostname, err)
}
if container.State.Running {
log.Infof(ctx, "Container [%s] is still running on host [%s]", containerName, hostname)
stderr, stdout, err := GetContainerLogsStdoutStderr(ctx, dClient, containerName, "1", false)
if err != nil {
logrus.Warnf("Failed to get container logs from container [%s] on host [%s]: %v", containerName, hostname, err)
}
log.Infof(ctx, "Container [%s] is still running on host [%s]: stderr: [%s], stdout: [%s]", containerName, hostname, stderr, stdout)
time.Sleep(1 * time.Second)
continue
}
logrus.Debugf("Exit code for [%s] container on host [%s] is [%d]", containerName, hostname, int64(container.State.ExitCode))
return int64(container.State.ExitCode), nil
}
return 1, fmt.Errorf("Container [%s] did not exit in time on host [%s]", containerName, hostname)
stderr, stdout, err := GetContainerLogsStdoutStderr(ctx, dClient, containerName, "1", false)
if err != nil {
logrus.Warnf("Failed to get container logs from container [%s] on host [%s]", containerName, hostname)
}
return 1, fmt.Errorf("Container [%s] did not exit in time on host [%s]: stderr: [%s], stdout: [%s]", containerName, hostname, stderr, stdout)
}
func IsContainerUpgradable(ctx context.Context, dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string) (bool, error) {