Skip to content
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
4 changes: 3 additions & 1 deletion pkg/controllers/podgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func (r *PodGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
case schedv1alpha1.PodGroupPending:
if len(pods) >= int(pg.Spec.MinMember) {
pgCopy.Status.Phase = schedv1alpha1.PodGroupScheduling
fillOccupiedObj(pgCopy, &pods[0])
if len(pods) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if the panic is really due to this 🤔 : If I understand correctly, the added len(pods) > 0 seems redundant because:

pg.Spec.MinMember is forced to be ≥ 1 by +kubebuilder:validation:Minimum=1

// +kubebuilder:validation:Minimum=1

The condition len(pods) >= int(pg.Spec.MinMember) already implies len(pods) >= 1

Therefore, it is safe to access pods[0] here, and the original code is correct.

Copy link
Member

Choose a reason for hiding this comment

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

fillOccupiedObj(pgCopy, &pods[0])
}
}
default:
pgCopy.Status.Running, pgCopy.Status.Succeeded, pgCopy.Status.Failed = getCurrentPodStats(pods)
Expand Down