mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #7403 from vmarmol/rkt-deps
Remove DockerPrefix references in Kubelet.
This commit is contained in:
commit
4b79e5a3db
@ -17,6 +17,8 @@ limitations under the License.
|
||||
package container
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
|
||||
)
|
||||
@ -37,3 +39,14 @@ type Prober interface {
|
||||
type RunContainerOptionsGenerator interface {
|
||||
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
|
||||
|
||||
// Set dead containers to unready state.
|
||||
for _, c := range resultStatus {
|
||||
// TODO(yifan): Unify the format of container ID. (i.e. including docker:// as prefix).
|
||||
readinessManager.RemoveReadiness(strings.TrimPrefix(c.ContainerID, dockertools.DockerPrefix))
|
||||
readinessManager.RemoveReadiness(kubecontainer.TrimRuntimePrefixFromImage(c.ContainerID))
|
||||
}
|
||||
|
||||
// Check RestartPolicy for dead container.
|
||||
@ -1653,7 +1652,7 @@ func (kl *Kubelet) validateContainerStatus(podStatus *api.PodStatus, containerNa
|
||||
if cStatus.State.Waiting != nil {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user