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

Tidy pod_issue_handler #2599

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Changes from all 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
18 changes: 6 additions & 12 deletions internal/executor/service/pod_issue_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (p *PodIssueService) detectPodIssues(allManagedPods []*v1.Pod) {
}

p.registerIssue(issue)
break
} else if pod.Status.Phase == v1.PodUnknown || pod.Status.Phase == v1.PodPending {

podEvents, err := p.clusterContext.GetPodEvents(pod)
Expand Down Expand Up @@ -177,15 +176,14 @@ func (p *PodIssueService) detectPodIssues(allManagedPods []*v1.Pod) {
Type: podIssueType,
}
p.registerIssue(issue)
break
}
}
}
}

func (p *PodIssueService) handleKnownPodIssues(ctx context.Context, allManagedPods []*v1.Pod) {
issues := createIssues(allManagedPods, p.knownPodIssues)
// Make issues from pods + issues
issues := createIssues(allManagedPods, p.knownPodIssues)
util.ProcessItemsWithThreadPool(ctx, 20, issues, p.handlePodIssue)
}

Expand All @@ -212,13 +210,9 @@ func createIssues(managedPods []*v1.Pod, podIssues map[string]*podIssue) []*issu
}

func (p *PodIssueService) handlePodIssue(issue *issue) {
// Skip jobs with no issues
if issue == nil {
return
}

hasSelfResolved := hasPodIssueSelfResolved(issue)
if hasSelfResolved {
log.Infof("Issue for job %s run %s has self resolved", issue.Issue.JobId, issue.Issue.RunId)
p.markIssuesResolved(issue.Issue)
return
}
Expand All @@ -237,6 +231,7 @@ func (p *PodIssueService) handlePodIssue(issue *issue) {
// Once that is done we are free to cleanup the pod
func (p *PodIssueService) handleNonRetryableJobIssue(issue *issue) {
if !issue.Issue.Reported {
log.Infof("Non-retryable issue detected for job %s run %s - %s", issue.Issue.JobId, issue.Issue.RunId, issue.Issue.Message)
message := issue.Issue.Message

events := make([]reporter.EventMessage, 0, 2)
Expand All @@ -252,7 +247,6 @@ func (p *PodIssueService) handleNonRetryableJobIssue(issue *issue) {
log.Errorf("Failed to report failed event for job %s because %s", issue.Issue.JobId, err)
return
}
log.Infof("Non-retryable issue detected for job %s run %s - %s", issue.Issue.JobId, issue.Issue.RunId, issue.Issue.Message)
p.markIssueReported(issue.Issue)
}

Expand All @@ -273,6 +267,7 @@ func (p *PodIssueService) handleNonRetryableJobIssue(issue *issue) {
// We must not return the lease if the pod state changes - as likely it has become "unstuck"
func (p *PodIssueService) handleRetryableJobIssue(issue *issue) {
if !issue.Issue.Reported {
log.Infof("Retryable issue detected for job %s run %s - %s", issue.Issue.JobId, issue.Issue.RunId, issue.Issue.Message)
if issue.Issue.Type == StuckStartingUp || issue.Issue.Type == UnableToSchedule {
event := reporter.CreateJobUnableToScheduleEvent(issue.Issue.OriginalPodState, issue.Issue.Message, p.clusterContext.GetClusterId())
err := p.eventReporter.Report([]reporter.EventMessage{{Event: event, JobRunId: issue.Issue.RunId}})
Expand All @@ -281,7 +276,6 @@ func (p *PodIssueService) handleRetryableJobIssue(issue *issue) {
return
}
}
log.Infof("Retryable issue detected for job %s run %s - %s", issue.Issue.JobId, issue.Issue.RunId, issue.Issue.Message)
p.markIssueReported(issue.Issue)
}

Expand Down Expand Up @@ -312,7 +306,7 @@ func (p *PodIssueService) handleRetryableJobIssue(issue *issue) {
}

func hasPodIssueSelfResolved(issue *issue) bool {
if issue == nil {
if issue == nil || issue.Issue == nil {
return true
}

Expand Down Expand Up @@ -359,7 +353,7 @@ func (p *PodIssueService) handleDeletedPod(pod *v1.Pod) {
OriginalPodState: pod,
JobId: jobId,
RunId: util.ExtractJobRunId(pod),
Message: "Pod was unexpected deleted",
Message: "Pod was unexpectedly deleted",
Retryable: false,
Reported: false,
Type: ExternallyDeleted,
Expand Down