Skip to content

Commit

Permalink
fix(pkg/repository/maintenance): don't panic when there's no containe…
Browse files Browse the repository at this point in the history
…r statuses

Signed-off-by: Mikaël Cluseau <[email protected]>
  • Loading branch information
mcluseau committed Oct 8, 2024
1 parent 42de654 commit 6f3a7c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelogs/unreleased/8271-mcluseau
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix(pkg/repository/maintenance): don't panic when there's no container statuses
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)
}

// 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 6f3a7c2

Please sign in to comment.