Skip to content

Commit

Permalink
fix ejob nil pointer bug
Browse files Browse the repository at this point in the history
Signed-off-by: JunjunLi <[email protected]>
  • Loading branch information
hellolijj committed Jul 7, 2022
1 parent 5380c57 commit 7f47cd8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apis/apps/v1alpha1/ephemeraljob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EphemeralJobSpec struct {

// Replicas indicates a part of the quantity from matched pods by selector.
// Usually it is used for gray scale working.
// if Replicas exceeded the matched number by selector, replicas will not work.
// if Replicas exceeded the matched number by selector or not be set, replicas will not work.
Replicas *int32 `json:"replicas,omitempty"`

// Parallelism specifies the maximum desired number of pods which matches running ephemeral containers.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/ephemeraljob/ephemeraljob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (r *ReconcileEphemeralJob) filterPods(job *appsv1alpha1.EphemeralJob) ([]*v
continue
}

if len(targetPods) < int(*job.Spec.Replicas) {
if job.Spec.Replicas == nil || len(targetPods) < int(*job.Spec.Replicas) {
targetPods = append(targetPods, &podList.Items[i])
}
}
Expand Down

0 comments on commit 7f47cd8

Please sign in to comment.