Skip to content

Commit

Permalink
check also for initcontianers in ShouldReap
Browse files Browse the repository at this point in the history
  • Loading branch information
c-apetrei committed Mar 19, 2024
1 parent e9657d4 commit b02149c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rules/container_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ func (rule *containerStatus) ShouldReap(pod v1.Pod) (bool, string) {
return true, fmt.Sprintf("has container status %s", reapStatus)
}
}

// Check init containers
for _, initContainerStatus := range pod.Status.InitContainerStatuses {
state := initContainerStatus.State
// Check both waiting and terminated conditions for init containers
if (state.Waiting != nil && state.Waiting.Reason == reapStatus) ||
(state.Terminated != nil && state.Terminated.Reason == reapStatus) {
return true, fmt.Sprintf("has init container status %s", reapStatus)
}
}
}
return false, ""
}

0 comments on commit b02149c

Please sign in to comment.