From 898fba46abfc2258a9e63b51b7e759d44081a07a Mon Sep 17 00:00:00 2001 From: Daniel Reuter Date: Tue, 5 Dec 2023 11:55:51 +0100 Subject: [PATCH] fix: crash loop pods - Cannot exec in a stopped container --- extpod/attack_cause_crashloop.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extpod/attack_cause_crashloop.go b/extpod/attack_cause_crashloop.go index 807e5d9..8255eee 100644 --- a/extpod/attack_cause_crashloop.go +++ b/extpod/attack_cause_crashloop.go @@ -165,11 +165,15 @@ func runKubectlExec(namespace, podName, containerName string, kubeExecCmd []stri if out, err := exec.Command(cmd[0], cmd[1:]...).CombinedOutput(); err != nil { if strings.Contains(string(out), "container not found") { - log.Debug().Msgf("Container %s in pod %s not found. Skipping.", containerName, podName) + log.Debug().Str("container", containerName).Str("pod", podName).Msg("Container not found. Skipping.") return nil } if strings.Contains(string(out), "failed to load task") { - log.Debug().Msgf("Container %s in pod %s not found (failed to load task). Skipping.", containerName, podName) + log.Debug().Str("container", containerName).Str("pod", podName).Msg("Failed to load taks. Skipping.") + return nil + } + if strings.Contains(string(out), "cannot exec in a stopped container") { + log.Debug().Str("container", containerName).Str("pod", podName).Msg("Cannot exec in a stopped container. Skipping.") return nil }