From 797d3165191847b60dda3d8e6822e2854462a118 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Wed, 13 Aug 2025 16:57:37 -0700 Subject: [PATCH] mark remaining md5 usage TODO and exclude from lint --- pkg/api/v1/endpoints/util.go | 9 +++++++++ pkg/kubelet/config/common.go | 3 +++ pkg/kubelet/volumemanager/reconciler/reconciler_test.go | 6 ++++++ .../src/k8s.io/endpointslice/util/controller_utils.go | 3 +++ staging/src/k8s.io/kubectl/pkg/util/util.go | 3 +++ 5 files changed, 24 insertions(+) diff --git a/pkg/api/v1/endpoints/util.go b/pkg/api/v1/endpoints/util.go index d0af83be274..9fe48cbb460 100644 --- a/pkg/api/v1/endpoints/util.go +++ b/pkg/api/v1/endpoints/util.go @@ -154,6 +154,9 @@ func hashAddresses(addrs addressSet) string { slice = append(slice, addrReady{k, ready}) } sort.Sort(addrsReady(slice)) + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo hasher := md5.New() hashutil.DeepHashObject(hasher, slice) return hex.EncodeToString(hasher.Sum(nil)[0:]) @@ -210,6 +213,9 @@ type subsetsByHash []v1.EndpointSubset func (sl subsetsByHash) Len() int { return len(sl) } func (sl subsetsByHash) Swap(i, j int) { sl[i], sl[j] = sl[j], sl[i] } func (sl subsetsByHash) Less(i, j int) bool { + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo hasher := md5.New() h1 := hashObject(hasher, sl[i]) h2 := hashObject(hasher, sl[j]) @@ -229,6 +235,9 @@ type portsByHash []v1.EndpointPort func (sl portsByHash) Len() int { return len(sl) } func (sl portsByHash) Swap(i, j int) { sl[i], sl[j] = sl[j], sl[i] } func (sl portsByHash) Less(i, j int) bool { + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo hasher := md5.New() h1 := hashObject(hasher, sl[i]) h2 := hashObject(hasher, sl[j]) diff --git a/pkg/kubelet/config/common.go b/pkg/kubelet/config/common.go index 3aeb35321a9..b7277dd995f 100644 --- a/pkg/kubelet/config/common.go +++ b/pkg/kubelet/config/common.go @@ -59,6 +59,9 @@ func generatePodName(name string, nodeName types.NodeName) string { func applyDefaults(logger klog.Logger, pod *api.Pod, source string, isFile bool, nodeName types.NodeName) error { if len(pod.UID) == 0 { + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo hasher := md5.New() hash.DeepHashObject(hasher, pod) // DeepHashObject resets the hash, so we should write the pod source diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go index fc898038e48..5759eb27207 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go @@ -1529,6 +1529,9 @@ func Test_UncertainDeviceGlobalMounts(t *testing.T) { tc := tests[tcIndex] testName := fmt.Sprintf("%s [%s]", tc.name, mode) uniqueTestString := fmt.Sprintf("global-mount-%s", testName) + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo uniquePodDir := fmt.Sprintf("%s-%x", kubeletPodsDir, md5.Sum([]byte(uniqueTestString))) t.Run(testName+"[", func(t *testing.T) { t.Parallel() @@ -1742,6 +1745,9 @@ func Test_UncertainVolumeMountState(t *testing.T) { tc := tests[tcIndex] testName := fmt.Sprintf("%s [%s]", tc.name, mode) uniqueTestString := fmt.Sprintf("local-mount-%s", testName) + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo uniquePodDir := fmt.Sprintf("%s-%x", kubeletPodsDir, md5.Sum([]byte(uniqueTestString))) t.Run(testName, func(t *testing.T) { t.Parallel() diff --git a/staging/src/k8s.io/endpointslice/util/controller_utils.go b/staging/src/k8s.io/endpointslice/util/controller_utils.go index 2a1f1cc144a..fb4dafb5e38 100644 --- a/staging/src/k8s.io/endpointslice/util/controller_utils.go +++ b/staging/src/k8s.io/endpointslice/util/controller_utils.go @@ -84,6 +84,9 @@ func NewPortMapKey(endpointPorts []discovery.EndpointPort) PortMapKey { // deepHashObjectToString creates a unique hash string from a go object. func deepHashObjectToString(objectToWrite interface{}) string { + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo hasher := md5.New() deepHashObject(hasher, objectToWrite) return hex.EncodeToString(hasher.Sum(nil)[0:]) diff --git a/staging/src/k8s.io/kubectl/pkg/util/util.go b/staging/src/k8s.io/kubectl/pkg/util/util.go index ea57d3b39bc..cf36a57b868 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/util.go +++ b/staging/src/k8s.io/kubectl/pkg/util/util.go @@ -47,6 +47,9 @@ func HashObject(obj runtime.Object, codec runtime.Codec) (string, error) { if err != nil { return "", err } + // TODO: finish removing existing md5 usage + // https://github.com/kubernetes/kubernetes/issues/129652 + //nolint:forbidigo return fmt.Sprintf("%x", md5.Sum(data)), nil }