Skip to content

Commit

Permalink
fix sidecarset hash without image is calculated differently when chan…
Browse files Browse the repository at this point in the history
…ging image tag to `latest`

Signed-off-by: joey <[email protected]>
  • Loading branch information
chengjoey committed Aug 6, 2024
1 parent 5a862a3 commit f4f961d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/control/sidecarcontrol/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f4f961d

Please sign in to comment.