1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 22:46:25 +00:00

Merge pull request #562 from moelsayed/update_cleanup

Make sure to clean up interrupted updates.
This commit is contained in:
Hussein Galal
2018-05-03 23:21:21 +02:00
committed by GitHub

View File

@@ -253,14 +253,24 @@ func InspectContainer(ctx context.Context, dClient *client.Client, hostname stri
} }
func StopRenameContainer(ctx context.Context, dClient *client.Client, hostname string, oldContainerName string, newContainerName string) error { func StopRenameContainer(ctx context.Context, dClient *client.Client, hostname string, oldContainerName string, newContainerName string) error {
// make sure we don't have an old old-container from a previous broken update
exists, err := IsContainerRunning(ctx, dClient, hostname, newContainerName, true)
if err != nil {
return err
}
if exists {
if err := RemoveContainer(ctx, dClient, hostname, newContainerName); err != nil {
return err
}
}
if err := StopContainer(ctx, dClient, hostname, oldContainerName); err != nil { if err := StopContainer(ctx, dClient, hostname, oldContainerName); err != nil {
return err return err
} }
if err := WaitForContainer(ctx, dClient, hostname, oldContainerName); err != nil { if err := WaitForContainer(ctx, dClient, hostname, oldContainerName); err != nil {
return nil return nil
} }
err := RenameContainer(ctx, dClient, hostname, oldContainerName, newContainerName) return RenameContainer(ctx, dClient, hostname, oldContainerName, newContainerName)
return err
} }
func WaitForContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string) error { func WaitForContainer(ctx context.Context, dClient *client.Client, hostname string, containerName string) error {