Skip to content

Commit

Permalink
fix: crash loop pods - Cannot exec in a stopped container
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuDa committed Dec 5, 2023
1 parent 06c9180 commit 898fba4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions extpod/attack_cause_crashloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 898fba4

Please sign in to comment.