Skip to content
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
3 changes: 3 additions & 0 deletions controllers/istiorevision/istiorevision_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@
return false, fmt.Errorf("failed to list pods: %w", err)
}
for _, pod := range podList.Items {
if pod.Status.Phase == corev1.PodSucceeded {
continue

Check warning on line 481 in controllers/istiorevision/istiorevision_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/istiorevision/istiorevision_controller.go#L481

Added line #L481 was not covered by tests
}
if ns, found := nsMap[pod.Namespace]; found && podReferencesRevision(pod, ns, rev) {
log.V(2).Info("Revision is referenced by Pod", "Pod", client.ObjectKeyFromObject(&pod))
return true, nil
Expand Down
14 changes: 14 additions & 0 deletions controllers/istiorevision/istiorevision_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ func TestDetermineInUseCondition(t *testing.T) {
podLabels map[string]string
podAnnotations map[string]string
nsLabels map[string]string
podPhase corev1.PodPhase
enableAllNamespaces bool
interceptors interceptor.Funcs
matchesRevision string
Expand All @@ -555,6 +556,13 @@ func TestDetermineInUseCondition(t *testing.T) {
matchesRevision: "default",
},

// pod succeeded
{
podAnnotations: map[string]string{"istio.io/rev": "default"},
podPhase: corev1.PodSucceeded,
matchesRevision: "",
},

// namespace labels only
{
nsLabels: map[string]string{"istio-injection": "enabled"},
Expand Down Expand Up @@ -687,6 +695,9 @@ func TestDetermineInUseCondition(t *testing.T) {
nameBuilder.WriteString(k + ":" + v + ",")
}
}
if len(tc.podPhase) > 0 {
nameBuilder.WriteString("Phase:" + string(tc.podPhase) + ",")
}
name := strings.TrimSuffix(nameBuilder.String(), ",")

t.Run(name, func(t *testing.T) {
Expand Down Expand Up @@ -723,6 +734,9 @@ func TestDetermineInUseCondition(t *testing.T) {
Labels: tc.podLabels,
Annotations: tc.podAnnotations,
},
Status: corev1.PodStatus{
Phase: tc.podPhase,
},
}

cl := fake.NewClientBuilder().
Expand Down
3 changes: 3 additions & 0 deletions controllers/istiorevisiontag/istiorevisiontag_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@
return false, fmt.Errorf("failed to list pods: %w", err)
}
for _, pod := range podList.Items {
if pod.Status.Phase == corev1.PodSucceeded {
continue

Check warning on line 379 in controllers/istiorevisiontag/istiorevisiontag_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/istiorevisiontag/istiorevisiontag_controller.go#L379

Added line #L379 was not covered by tests
}
if ns, found := nsMap[pod.Namespace]; found && podReferencesRevisionTag(pod, tag, ns) {
log.V(2).Info("RevisionTag is referenced by Pod", "Pod", client.ObjectKeyFromObject(&pod))
return true, nil
Expand Down