diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aed398..00c9b9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # pod-reaper: kills pods dead +### 2.13.0 +- the reaper checks now also the initContainerStatus + ### 2.7.0 - add `DRY_RUN` mode diff --git a/rules/container_status.go b/rules/container_status.go index 57fc7e0..64f7e7e 100644 --- a/rules/container_status.go +++ b/rules/container_status.go @@ -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, "" }