Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
free6om committed Apr 25, 2024
1 parent 2d59424 commit b7adced
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/instanceset/instance_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func validateSpec(its *workloads.InstanceSet, tree *kubebuilderx.ObjectTree) err
replicasInTemplates += replicas
if templateNames.Has(template.Name) {
err = fmt.Errorf("duplicate instance template name: %s", template.Name)
if tree.EventRecorder != nil {
if tree != nil {
tree.EventRecorder.Event(its, corev1.EventTypeWarning, EventReasonInvalidSpec, err.Error())
}
return err
Expand All @@ -444,7 +444,7 @@ func validateSpec(its *workloads.InstanceSet, tree *kubebuilderx.ObjectTree) err
// sum of spec.templates[*].replicas should not greater than spec.replicas
if replicasInTemplates > *its.Spec.Replicas {
err = fmt.Errorf("total replicas in instances(%d) should not greater than replicas in spec(%d)", replicasInTemplates, *its.Spec.Replicas)
if tree.EventRecorder != nil {
if tree != nil {
tree.EventRecorder.Event(its, corev1.EventTypeWarning, EventReasonInvalidSpec, err.Error())
}
return err
Expand Down

0 comments on commit b7adced

Please sign in to comment.