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

[release-1.2] 🐛 Remove unique patch ID from TopologyReconcile conditions #7357

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
19 changes: 10 additions & 9 deletions internal/controllers/topology/cluster/patches/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ func applyPatchesToRequest(ctx context.Context, req *runtimehooksv1.GeneratePatc

// If a patch doesn't have a corresponding request item, the patch is invalid.
if requestItem == nil {
return errors.Errorf("unable to find corresponding request item with uid %q for the patch", patch.UID)
log.Infof("Unable to find corresponding request item with uid %q for the patch", patch.UID)
return errors.Errorf("unable to find corresponding request item for patch")
}

// Use the patch to create a patched copy of the template.
Expand All @@ -302,29 +303,29 @@ func applyPatchesToRequest(ctx context.Context, req *runtimehooksv1.GeneratePatc
log.V(5).Infof("Accumulating JSON patch: %s", string(patch.Patch))
jsonPatch, err := jsonpatch.DecodePatch(patch.Patch)
if err != nil {
return errors.Wrapf(err, "failed to apply patch with uid %q: error decoding json patch (RFC6902): %s",
requestItem.UID, string(patch.Patch))
log.Infof("Failed to apply patch with uid %q: error decoding json patch (RFC6902): %s: %s", requestItem.UID, string(patch.Patch), err)
return errors.Wrap(err, "failed to apply patch: error decoding json patch (RFC6902)")
}

patchedTemplate, err = jsonPatch.Apply(requestItem.Object.Raw)
if err != nil {
return errors.Wrapf(err, "failed to apply patch with uid %q: error applying json patch (RFC6902): %s",
requestItem.UID, string(patch.Patch))
log.Infof("Failed to apply patch with uid %q: error applying json patch (RFC6902): %s: %s", requestItem.UID, string(patch.Patch), err)
return errors.Wrap(err, "failed to apply patch: error applying json patch (RFC6902)")
}
case runtimehooksv1.JSONMergePatchType:
log.V(5).Infof("Accumulating JSON merge patch: %s", string(patch.Patch))
patchedTemplate, err = jsonpatch.MergePatch(requestItem.Object.Raw, patch.Patch)
if err != nil {
return errors.Wrapf(err, "failed to apply patch with uid %q: error applying json merge patch (RFC7386): %s",
requestItem.UID, string(patch.Patch))
log.Infof("Failed to apply patch with uid %q: error applying json merge patch (RFC7386): %s: %s", requestItem.UID, string(patch.Patch), err)
return errors.Wrap(err, "failed to apply patch: error applying json merge patch (RFC7386)")
}
}

// Overwrite the spec of template.Template with the spec of the patchedTemplate,
// to ensure that we only pick up changes to the spec.
if err := patchTemplateSpec(&requestItem.Object, patchedTemplate); err != nil {
return errors.Wrapf(err, "failed to apply patch to template %s",
requestItem.UID)
log.Infof("Failed to apply patch to template %s: %s", requestItem.UID, err)
return errors.Wrap(err, "failed to apply patch to template")
}
}
return nil
Expand Down