diff --git a/pkg/kubelet/dockershim/docker_container.go b/pkg/kubelet/dockershim/docker_container.go index 147c7e59b1..61401ee1fa 100644 --- a/pkg/kubelet/dockershim/docker_container.go +++ b/pkg/kubelet/dockershim/docker_container.go @@ -232,18 +232,21 @@ func (ds *dockerService) removeContainerLogSymlink(containerID string) error { // StartContainer starts the container. func (ds *dockerService) StartContainer(containerID string) error { err := ds.client.StartContainer(containerID) - if err != nil { - err = transformStartContainerError(err) - return fmt.Errorf("failed to start container %q: %v", containerID, err) - } - // Create container log symlink. - if err := ds.createContainerLogSymlink(containerID); err != nil { + + // Create container log symlink for all containers (including failed ones). + if linkError := ds.createContainerLogSymlink(containerID); linkError != nil { // Do not stop the container if we failed to create symlink because: // 1. This is not a critical failure. // 2. We don't have enough information to properly stop container here. // Kubelet will surface this error to user via an event. - return err + return linkError } + + if err != nil { + err = transformStartContainerError(err) + return fmt.Errorf("failed to start container %q: %v", containerID, err) + } + return nil }