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

[v0.10] Prevent empty Patch updates #3254

Open
wants to merge 1 commit into
base: release/v0.10
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ func (r *BundleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req

func (r *BundleDeploymentReconciler) updateStatus(ctx context.Context, orig *fleetv1.BundleDeployment, obj *fleetv1.BundleDeployment) error {
statusPatch := client.MergeFrom(orig)
if patchData, err := statusPatch.Data(obj); err == nil && string(patchData) == "{}" {
// skip update if patch is empty
return nil
}
return r.Status().Patch(ctx, obj, statusPatch)
}

Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/controller/reconciler/bundle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,12 @@ func (r *BundleReconciler) getOCIReference(ctx context.Context, bundle *fleet.Bu
func (r *BundleReconciler) updateStatus(ctx context.Context, orig *fleet.Bundle, bundle *fleet.Bundle) error {
logger := log.FromContext(ctx).WithName("bundle - updateStatus")
statusPatch := client.MergeFrom(orig)
err := r.Status().Patch(ctx, bundle, statusPatch)
if err != nil {

if patchData, err := statusPatch.Data(bundle); err == nil && string(patchData) == "{}" {
// skip update if patch is empty
return nil
}
if err := r.Status().Patch(ctx, bundle, statusPatch); err != nil {
logger.V(1).Info("Reconcile failed update to bundle status", "status", bundle.Status, "error", err)
return err
}
Expand Down
Loading