Skip to content

Commit

Permalink
Skip initActionSetStatus() if status is already present (#1267)
Browse files Browse the repository at this point in the history
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
PrasadG193 and mergify[bot] committed Mar 24, 2022
1 parent ac4bbb7 commit b202ce6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ func (c *Controller) onAddActionSet(as *crv1alpha1.ActionSet) error {
if err := validate.ActionSet(as); err != nil {
return err
}
c.initActionSetStatus(as)
if as.Status == nil {
c.initActionSetStatus(as)
}
as, err = c.crClient.CrV1alpha1().ActionSets(as.GetNamespace()).Get(context.TODO(), as.GetName(), v1.GetOptions{})
if err != nil {
return errors.WithStack(err)
Expand Down Expand Up @@ -278,10 +280,6 @@ func (c *Controller) initActionSetStatus(as *crv1alpha1.ActionSet) {
log.Error().WithContext(ctx).Print("Cannot initialize an ActionSet without a spec.")
return
}
if as.Status != nil {
log.Error().WithContext(ctx).Print("Cannot initialize non-nil ActionSet Status")
return
}
as.Status = &crv1alpha1.ActionSetStatus{State: crv1alpha1.StatePending}
actions := make([]crv1alpha1.ActionStatus, 0, len(as.Spec.Actions))
var err error
Expand Down

0 comments on commit b202ce6

Please sign in to comment.