mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
kubelet: Move HashContainer to kubelet/container package.
This commit is contained in:
@@ -18,7 +18,6 @@ package dockertools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -26,6 +25,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
||||
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/leaky"
|
||||
kubeletTypes "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/types"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||
@@ -212,15 +212,9 @@ func (c DockerContainers) FindPodContainer(podFullName string, uid types.UID, co
|
||||
|
||||
const containerNamePrefix = "k8s"
|
||||
|
||||
func HashContainer(container *api.Container) uint64 {
|
||||
hash := adler32.New()
|
||||
util.DeepHashObject(hash, *container)
|
||||
return uint64(hash.Sum32())
|
||||
}
|
||||
|
||||
// Creates a name which can be reversed to identify both full pod name and container name.
|
||||
func BuildDockerName(dockerName KubeletContainerName, container *api.Container) string {
|
||||
containerName := dockerName.ContainerName + "." + strconv.FormatUint(HashContainer(container), 16)
|
||||
containerName := dockerName.ContainerName + "." + strconv.FormatUint(kubecontainer.HashContainer(container), 16)
|
||||
return fmt.Sprintf("%s_%s_%s_%s_%08x",
|
||||
containerNamePrefix,
|
||||
containerName,
|
||||
|
@@ -824,7 +824,7 @@ func (dm *DockerManager) podInfraContainerChanged(pod *api.Pod, podInfraContaine
|
||||
Image: dm.PodInfraContainerImage,
|
||||
Ports: ports,
|
||||
}
|
||||
return podInfraContainer.Hash != HashContainer(expectedPodInfraContainer), nil
|
||||
return podInfraContainer.Hash != kubecontainer.HashContainer(expectedPodInfraContainer), nil
|
||||
}
|
||||
|
||||
type dockerVersion docker.APIVersion
|
||||
@@ -1355,7 +1355,7 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
|
||||
}
|
||||
|
||||
for index, container := range pod.Spec.Containers {
|
||||
expectedHash := HashContainer(&container)
|
||||
expectedHash := kubecontainer.HashContainer(&container)
|
||||
|
||||
c := runningPod.FindContainerByName(container.Name)
|
||||
if c == nil {
|
||||
|
Reference in New Issue
Block a user