Skip to content

Commit

Permalink
[KFLUXBUGS-1105]: Retrieve Component before updating status for build…
Browse files Browse the repository at this point in the history
…-nudged-by (#444)

* [KFLUXBUGS-1105]: Retrieve Component before updating status

Signed-off-by: John Collier <[email protected]>

* Add log

Signed-off-by: John Collier <[email protected]>

---------

Signed-off-by: John Collier <[email protected]>
  • Loading branch information
johnmcollier authored Feb 13, 2024
1 parent 3041882 commit 4863efd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions controllers/webhooks/component_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,22 @@ 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)
err := 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
})
if err != nil {
componentlog.Error(err, "error setting build-nudged-by in status")
}

}

}
Expand Down

0 comments on commit 4863efd

Please sign in to comment.