Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KFLUXBUGS-1105]: Retrieve Component before updating status for build-nudged-by #444

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

// 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
}

Check warning on line 96 in controllers/webhooks/component_webhook.go

View check run for this annotation

Codecov / codecov/patch

controllers/webhooks/component_webhook.go#L95-L96

Added lines #L95 - L96 were not covered by tests
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")
}

Check warning on line 103 in controllers/webhooks/component_webhook.go

View check run for this annotation

Codecov / codecov/patch

controllers/webhooks/component_webhook.go#L102-L103

Added lines #L102 - L103 were not covered by tests

}

}
Expand Down
Loading