Skip to content

Commit

Permalink
🐛 Detect immage issues.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Jun 27, 2024
1 parent 9b4cc38 commit 89feb66
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
const (
AddonSelected = "AddonSelected"
ExtSelected = "ExtensionSelected"
ImageError = "ImageError"
PodNotFound = "PodNotFound"
PodCreated = "PodCreated"
PodRunning = "PodRunning"
Expand Down Expand Up @@ -945,6 +946,9 @@ func (m *Manager) podEvent(pod *core.Pod) (events []Event, err error) {

// podLogs - get and store pod logs as a Files.
func (m *Manager) podLogs(pod *core.Pod) (files []*model.File, err error) {
if pod.Status.Phase == core.PodPending {
return
}
for _, container := range pod.Spec.Containers {
f, nErr := m.containerLog(pod, container.Name)
if nErr == nil {
Expand Down Expand Up @@ -1233,6 +1237,23 @@ func (r *Task) podPending(pod *core.Pod) {
status,
pod.Status.ContainerStatuses...)
for _, status := range status {
state := status.State
if state.Waiting != nil {
waiting := state.Waiting
reason := strings.ToLower(waiting.Reason)
if strings.Contains(reason, "invalid") || strings.Contains(reason, "backoff") {
r.Error(
"Error",
"Container (%s) failed: %s",
status.Name,
waiting.Reason)
mark := time.Now()
r.Terminated = &mark
r.Event(ImageError, waiting.Reason)
r.State = Failed
return
}
}
if status.Started == nil {
continue
}
Expand Down

0 comments on commit 89feb66

Please sign in to comment.