diff --git a/pkg/kubelet/dockershim/docker_container.go b/pkg/kubelet/dockershim/docker_container.go index 283dc644dbd..ac79f3fe64a 100644 --- a/pkg/kubelet/dockershim/docker_container.go +++ b/pkg/kubelet/dockershim/docker_container.go @@ -233,6 +233,7 @@ func (ds *dockerService) removeContainerLogSymlink(containerID string) error { 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. diff --git a/pkg/kubelet/dockershim/helpers.go b/pkg/kubelet/dockershim/helpers.go index 22ab777e6af..c5b99a32d57 100644 --- a/pkg/kubelet/dockershim/helpers.go +++ b/pkg/kubelet/dockershim/helpers.go @@ -55,6 +55,10 @@ const ( var ( conflictRE = regexp.MustCompile(`Conflict. (?:.)+ is already in use by container ([0-9a-z]+)`) + // this is hacky, but extremely common. + // if a container starts but the executable file is not found, runc gives a message that matches + startRE = regexp.MustCompile(`\\\\\\\"(.*)\\\\\\\": executable file not found`) + // Docker changes the security option separator from ':' to '=' in the 1.23 // API version. optsSeparatorChangeVersion = semver.MustParse(securityOptSeparatorChangeVersion) @@ -359,6 +363,19 @@ func recoverFromCreationConflictIfNeeded(client libdocker.Interface, createConfi return client.CreateContainer(createConfig) } +// transformStartContainerError does regex parsing on returned error +// for where container runtimes are giving less than ideal error messages. +func transformStartContainerError(err error) error { + if err == nil { + return nil + } + matches := startRE.FindStringSubmatch(err.Error()) + if len(matches) > 0 { + return fmt.Errorf("executable not found in $PATH") + } + return err +} + // getSecurityOptSeparator returns the security option separator based on the // docker API version. // TODO: Remove this function along with the relevant code when we no longer