Commit 4b79e5a3 authored by Dawn Chen's avatar Dawn Chen

Merge pull request #7403 from vmarmol/rkt-deps

Remove DockerPrefix references in Kubelet.
parents 0c611370 42a2059a
...@@ -17,6 +17,8 @@ limitations under the License. ...@@ -17,6 +17,8 @@ limitations under the License.
package container package container
import ( import (
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe" "github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
) )
...@@ -37,3 +39,14 @@ type Prober interface { ...@@ -37,3 +39,14 @@ type Prober interface {
type RunContainerOptionsGenerator interface { type RunContainerOptionsGenerator interface {
GenerateRunContainerOptions(pod *api.Pod, container *api.Container, netMode, ipcMode string) (*RunContainerOptions, error) GenerateRunContainerOptions(pod *api.Pod, container *api.Container, netMode, ipcMode string) (*RunContainerOptions, error)
} }
// Trims runtime prefix from image name (e.g.: docker://busybox -> busybox).
func TrimRuntimePrefixFromImage(img string) string {
const prefixSeparator = "://"
idx := strings.Index(img, prefixSeparator)
if idx < 0 {
return img
}
return img[idx+len(prefixSeparator):]
}
...@@ -934,8 +934,7 @@ func shouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu ...@@ -934,8 +934,7 @@ func shouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
// Set dead containers to unready state. // Set dead containers to unready state.
for _, c := range resultStatus { for _, c := range resultStatus {
// TODO(yifan): Unify the format of container ID. (i.e. including docker:// as prefix). readinessManager.RemoveReadiness(kubecontainer.TrimRuntimePrefixFromImage(c.ContainerID))
readinessManager.RemoveReadiness(strings.TrimPrefix(c.ContainerID, dockertools.DockerPrefix))
} }
// Check RestartPolicy for dead container. // Check RestartPolicy for dead container.
...@@ -1653,7 +1652,7 @@ func (kl *Kubelet) validateContainerStatus(podStatus *api.PodStatus, containerNa ...@@ -1653,7 +1652,7 @@ func (kl *Kubelet) validateContainerStatus(podStatus *api.PodStatus, containerNa
if cStatus.State.Waiting != nil { if cStatus.State.Waiting != nil {
return "", fmt.Errorf("container %q is in waiting state.", containerName) return "", fmt.Errorf("container %q is in waiting state.", containerName)
} }
return strings.Replace(cStatus.ContainerID, dockertools.DockerPrefix, "", 1), nil return kubecontainer.TrimRuntimePrefixFromImage(cStatus.ContainerID), nil
} }
// GetKubeletContainerLogs returns logs from the container // GetKubeletContainerLogs returns logs from the container
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment