Skip to content

Commit

Permalink
fix(pkg/repository/maintenance): handle when there's no container sta…
Browse files Browse the repository at this point in the history
…tuses

Signed-off-by: Mikaël Cluseau <[email protected]>
  • Loading branch information
mcluseau committed Oct 7, 2024
1 parent 42de654 commit beb20dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/repository/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ func GetMaintenanceResultFromJob(cli client.Client, job *batchv1.Job) (string, e
}

// we only have one maintenance pod for the job
return podList.Items[0].Status.ContainerStatuses[0].State.Terminated.Message, nil
pod := podList.Items[0]

statuses := pod.Status.ContainerStatuses
if len(statuses) == 0 {
return "", fmt.Errorf("no container statuses found for job %s", job.Name)

Check warning on line 124 in pkg/repository/maintenance.go

View check run for this annotation

Codecov / codecov/patch

pkg/repository/maintenance.go#L124

Added line #L124 was not covered by tests
}

// we only have one maintenance container
return statuses[0].State.Terminated.Message, nil
}

func GetLatestMaintenanceJob(cli client.Client, ns string) (*batchv1.Job, error) {
Expand Down

0 comments on commit beb20dd

Please sign in to comment.