Skip to content

Commit

Permalink
[KFLUXBUGS-1105]: Retrieve Component before updating status
Browse files Browse the repository at this point in the history
Signed-off-by: John Collier <jcollier@redhat.com>
  • Loading branch information
johnmcollier committed Feb 13, 2024
1 parent 3041882 commit f0c4e21
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions controllers/webhooks/component_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,19 @@ func (r *ComponentWebhook) UpdateNudgedComponentStatus(ctx context.Context, obj

// Add the component to the status if it's not already present
if !util.StrInList(compName, nudgedComp.Status.BuildNudgedBy) {
nudgedComp.Status.BuildNudgedBy = append(nudgedComp.Status.BuildNudgedBy, compName)

// Update the Component's status - retry on conflict
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
err = r.client.Status().Update(ctx, nudgedComp)
retry.RetryOnConflict(retry.DefaultRetry, func() error {
currentNudgedComp := &appstudiov1alpha1.Component{}
err := r.client.Get(ctx, types.NamespacedName{Namespace: comp.Namespace, Name: nudgedCompName}, currentNudgedComp)
if err != nil {
return err
}
currentNudgedComp.Status.BuildNudgedBy = append(currentNudgedComp.Status.BuildNudgedBy, compName)
err = r.client.Status().Update(ctx, currentNudgedComp)
return err
})

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.

}

}
Expand Down

0 comments on commit f0c4e21

Please sign in to comment.