From 5464ef200ec78f738859cd35ca29dfd92f8407ee Mon Sep 17 00:00:00 2001 From: deviantony Date: Thu, 21 Sep 2023 07:42:17 +0000 Subject: [PATCH] fix: display error message when container update fails --- internal/adapter/container_utils.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/adapter/container_utils.go b/internal/adapter/container_utils.go index dfc461d..02bbba6 100644 --- a/internal/adapter/container_utils.go +++ b/internal/adapter/container_utils.go @@ -92,16 +92,18 @@ func (adapter *KubeDockerAdapter) reCreateContainerWithNewConfiguration(ctx cont if err != nil { // If the new container fails to start, remove the old container and leave the new container in the created state. // This way, the container can be inspected to see what went wrong. - if removeErr := adapter.cli.ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{}); removeErr != nil { + removeErr := adapter.cli.ContainerRemove(ctx, containerID, types.ContainerRemoveOptions{}) + if removeErr != nil { return fmt.Errorf("unable to remove the old container after failed start: %w", removeErr) } // Rename the new container to the original name // This way, the container with the known name can be inspected to see what went wrong. - err = adapter.cli.ContainerRename(ctx, containerCreateResponse.ID, newContainerCfg.ContainerName) - if err != nil { - return fmt.Errorf("unable to rename container for the new container: %w", err) + renameErr := adapter.cli.ContainerRename(ctx, containerCreateResponse.ID, newContainerCfg.ContainerName) + if renameErr != nil { + return fmt.Errorf("unable to rename container for the new container: %w", renameErr) } + return fmt.Errorf("unable to start container: %w", err) }