mirror of
https://github.com/rancher/rke.git
synced 2025-04-28 03:31:24 +00:00
Add host to wait for container check
This commit is contained in:
parent
192182c5d6
commit
c2ad3d5c4d
@ -428,7 +428,7 @@ func checkPlaneTCPPortsFromHost(ctx context.Context, host *hosts.Host, portList
|
||||
if err := docker.DoRunContainer(ctx, host.DClient, imageCfg, hostCfg, PortCheckContainer, host.Address, "network", prsMap); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := docker.WaitForContainer(ctx, host.DClient, PortCheckContainer); err != nil {
|
||||
if err := docker.WaitForContainer(ctx, host.DClient, host.Address, PortCheckContainer); err != nil {
|
||||
return err
|
||||
}
|
||||
logs, err := docker.ReadContainerLogs(ctx, host.DClient, PortCheckContainer)
|
||||
|
@ -268,19 +268,19 @@ func StopRenameContainer(ctx context.Context, dClient *client.Client, hostname s
|
||||
if err := StopContainer(ctx, dClient, hostname, oldContainerName); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := WaitForContainer(ctx, dClient, oldContainerName); err != nil {
|
||||
if err := WaitForContainer(ctx, dClient, hostname, oldContainerName); err != nil {
|
||||
return nil
|
||||
}
|
||||
err := RenameContainer(ctx, dClient, hostname, oldContainerName, newContainerName)
|
||||
return err
|
||||
}
|
||||
|
||||
func WaitForContainer(ctx context.Context, dClient *client.Client, containerName string) error {
|
||||
func WaitForContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string) error {
|
||||
statusCh, errCh := dClient.ContainerWait(ctx, containerName, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error wating for container [%s]: %v", containerName, err)
|
||||
return fmt.Errorf("Error waiting for container [%s] on host [%s]: %v", containerName, hostname, err)
|
||||
}
|
||||
case <-statusCh:
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (h *Host) CleanUp(ctx context.Context, toCleanPaths []string, cleanerImage
|
||||
return err
|
||||
}
|
||||
|
||||
if err := docker.WaitForContainer(ctx, h.DClient, CleanerContainerName); err != nil {
|
||||
if err := docker.WaitForContainer(ctx, h.DClient, h.Address, CleanerContainerName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user