From f4f961d617a4aa9ef0606b1ba961278918fc7304 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 6 Aug 2024 23:37:04 +0800 Subject: [PATCH] fix sidecarset hash without image is calculated differently when changing image tag to `latest` Signed-off-by: joey --- pkg/control/sidecarcontrol/hash.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/control/sidecarcontrol/hash.go b/pkg/control/sidecarcontrol/hash.go index be631500d5..ae308abc5e 100644 --- a/pkg/control/sidecarcontrol/hash.go +++ b/pkg/control/sidecarcontrol/hash.go @@ -37,14 +37,17 @@ func SidecarSetHash(sidecarSet *appsv1alpha1.SidecarSet) (string, error) { } // SidecarSetHashWithoutImage calculates sidecars's container hash without its image +// also ignore ImagePullPolicy, because if change image tag to `latest`, the ImagePullPolicy will be set to `Always` as default. // we use this to determine if the sidecar reconcile needs to update a pod image func SidecarSetHashWithoutImage(sidecarSet *appsv1alpha1.SidecarSet) (string, error) { ss := sidecarSet.DeepCopy() for i := range ss.Spec.Containers { ss.Spec.Containers[i].Image = "" + ss.Spec.Containers[i].ImagePullPolicy = "" } for i := range ss.Spec.InitContainers { ss.Spec.InitContainers[i].Image = "" + ss.Spec.InitContainers[i].ImagePullPolicy = "" } encoded, err := encodeSidecarSet(ss) if err != nil {