diff --git a/pkg/controller/instanceset/instance_util.go b/pkg/controller/instanceset/instance_util.go index 638d4b1bdaa..11812f5b36b 100644 --- a/pkg/controller/instanceset/instance_util.go +++ b/pkg/controller/instanceset/instance_util.go @@ -232,10 +232,12 @@ func isImageMatched(pod *corev1.Pod) bool { return false } // otherwise, statusName should be same as or has suffix of specName - // remove registry and repository in specName (if presents) - names := strings.Split(specName, "/") - if !strings.HasSuffix(statusName, "/"+names[len(names)-1]) { - return false + if specName != statusName { + specNames := strings.Split(specName, "/") + statusNames := strings.Split(statusName, "/") + if specNames[len(specNames)-1] != statusNames[len(statusNames)-1] { + return false + } } } return true diff --git a/pkg/controller/instanceset/instance_util_test.go b/pkg/controller/instanceset/instance_util_test.go index 6dcbeea0d43..4df3482d72a 100644 --- a/pkg/controller/instanceset/instance_util_test.go +++ b/pkg/controller/instanceset/instance_util_test.go @@ -1404,6 +1404,13 @@ var _ = Describe("instance util test", func() { }} Expect(isImageMatched(pod)).Should(BeTrue()) + By("exactly match w/o registry and repository") + pod.Status.ContainerStatuses = []corev1.ContainerStatus{{ + Name: name, + Image: "nginx", + }} + Expect(isImageMatched(pod)).Should(BeTrue()) + By("digest not matches") pod.Spec.Containers = []corev1.Container{{ Name: name,