mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Merge pull request #6004 from yifan-gu/ref_manager
kubelet: Move container reference manager to pkg/kubelet/container.
This commit is contained in:
@@ -218,7 +218,7 @@ func NewMainKubelet(
|
||||
rootDirectory: rootDirectory,
|
||||
resyncInterval: resyncInterval,
|
||||
podInfraContainerImage: podInfraContainerImage,
|
||||
containerRefManager: newContainerRefManager(),
|
||||
containerRefManager: kubecontainer.NewRefManager(),
|
||||
runner: dockertools.NewDockerContainerCommandRunner(dockerClient),
|
||||
httpClient: &http.Client{},
|
||||
pullQPS: pullQPS,
|
||||
@@ -296,7 +296,7 @@ type Kubelet struct {
|
||||
|
||||
// Needed to report events for containers belonging to deleted/modified pods.
|
||||
// Tracks references for reporting events
|
||||
containerRefManager *ContainerRefManager
|
||||
containerRefManager *kubecontainer.RefManager
|
||||
|
||||
// Optional, defaults to simple Docker implementation
|
||||
dockerPuller dockertools.DockerPuller
|
||||
@@ -668,22 +668,6 @@ func (kl *Kubelet) runHandler(podFullName string, uid types.UID, container *api.
|
||||
return actionHandler.Run(podFullName, uid, container, handler)
|
||||
}
|
||||
|
||||
// fieldPath returns a fieldPath locating container within pod.
|
||||
// Returns an error if the container isn't part of the pod.
|
||||
func fieldPath(pod *api.Pod, container *api.Container) (string, error) {
|
||||
for i := range pod.Spec.Containers {
|
||||
here := &pod.Spec.Containers[i]
|
||||
if here.Name == container.Name {
|
||||
if here.Name == "" {
|
||||
return fmt.Sprintf("spec.containers[%d]", i), nil
|
||||
} else {
|
||||
return fmt.Sprintf("spec.containers{%s}", here.Name), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("container %#v not found in pod %#v", container, pod)
|
||||
}
|
||||
|
||||
// Run a single container from a pod. Returns the docker container ID
|
||||
func (kl *Kubelet) runContainer(pod *api.Pod, container *api.Container, podVolumes volumeMap, netMode, ipcMode string) (id dockertools.DockerID, err error) {
|
||||
ref, err := kl.containerRefManager.GenerateContainerRef(pod, container)
|
||||
|
Reference in New Issue
Block a user