Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update the pod image that does not have a registry and repository specified #8497

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/controller/instanceset/instance_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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,
Expand Down
Loading