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 6, 2024
1 parent 42de654 commit 2071e06
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/repository/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ func GetMaintenanceResultFromJob(cli client.Client, job *batchv1.Job) (string, e
return "", fmt.Errorf("no pod found for job %s", job.Name)
}

// 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 pod %s", pod.Name)
}

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

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

0 comments on commit 2071e06

Please sign in to comment.