Skip to content

Commit

Permalink
chore: update the pod image that does not have a registry and reposit…
Browse files Browse the repository at this point in the history
…ory specified (#8493)
  • Loading branch information
leon-inf authored Nov 21, 2024
1 parent 9776e82 commit fe24a3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/controller/instanceset/instance_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,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
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/instanceset/instance_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,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,
Expand Down

0 comments on commit fe24a3a

Please sign in to comment.