Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Detect image issues. #678

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion 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,7 +946,13 @@ 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) {
for _, container := range pod.Spec.Containers {
for _, container := range pod.Status.ContainerStatuses {
if container.Started == nil {
continue
}
if !*container.Started {
continue
}
f, nErr := m.containerLog(pod, container.Name)
if nErr == nil {
files = append(files, f)
Expand Down Expand Up @@ -1233,6 +1240,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") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to specifically match ImagePullBackOff and InvalidImageName, if those are the only cases we intend to catch?

Copy link
Contributor Author

@jortel jortel Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps but I cannot find a const in v1 or core packages and concerned about making the match too narrow should the strings change a little. Also, a little broader match may catch other similar issues.
I cannot find an Enum for all the possible values.

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
Loading