From de6fc49a99001f544be1e0c345c1d94495df1210 Mon Sep 17 00:00:00 2001 From: houjun Date: Tue, 28 Dec 2021 15:48:53 +0800 Subject: [PATCH] pointer usage error --- pkg/controller/daemon/util/daemonset_util.go | 2 +- pkg/controller/daemon/util/daemonset_util_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/controller/daemon/util/daemonset_util.go b/pkg/controller/daemon/util/daemonset_util.go index acff170506c..5058f747df3 100644 --- a/pkg/controller/daemon/util/daemonset_util.go +++ b/pkg/controller/daemon/util/daemonset_util.go @@ -169,7 +169,7 @@ func UnavailableCount(ds *apps.DaemonSet, numberToSchedule int) (int, error) { func IsPodUpdated(pod *v1.Pod, hash string, dsTemplateGeneration *int64) bool { // Compare with hash to see if the pod is updated, need to maintain backward compatibility of templateGeneration templateMatches := dsTemplateGeneration != nil && - pod.Labels[extensions.DaemonSetTemplateGenerationKey] == fmt.Sprint(dsTemplateGeneration) + pod.Labels[extensions.DaemonSetTemplateGenerationKey] == fmt.Sprint(*dsTemplateGeneration) hashMatches := len(hash) > 0 && pod.Labels[extensions.DefaultDaemonSetUniqueLabelKey] == hash return hashMatches || templateMatches } diff --git a/pkg/controller/daemon/util/daemonset_util_test.go b/pkg/controller/daemon/util/daemonset_util_test.go index e7dfba56092..de34f6f0803 100644 --- a/pkg/controller/daemon/util/daemonset_util_test.go +++ b/pkg/controller/daemon/util/daemonset_util_test.go @@ -52,10 +52,10 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod { func TestIsPodUpdated(t *testing.T) { templateGeneration := utilpointer.Int64Ptr(12345) - badGeneration := utilpointer.Int64Ptr(12345) + badGeneration := utilpointer.Int64Ptr(12350) hash := "55555" - labels := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration), extensions.DefaultDaemonSetUniqueLabelKey: hash} - labelsNoHash := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration)} + labels := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(*templateGeneration), extensions.DefaultDaemonSetUniqueLabelKey: hash} + labelsNoHash := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(*templateGeneration)} tests := []struct { test string templateGeneration *int64