-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: provide option to control reconciliation when creating resources #974
feat: provide option to control reconciliation when creating resources #974
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this work! That was the big missing piece to make Features
more suitable for operator use cases.
A few things in this review:
- important calling
Update
vsPatch
(server-side apply) (open for discussion, that's why I tagged @aslakknutsen). The kustomizedeploy.go
logic does the latter. - some minor simplifications in the manifest logic
- remark about the focus of the tests (🏅 for writing them, my suggestion is about what is the subject of the test, but the foundation is solid!)
pkg/feature/raw_resources.go
Outdated
if exists && managed == "true" { | ||
// update or create object since we manage it | ||
if err == nil { | ||
if err := cli.Update(context.TODO(), object); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we don't want to make server-side apply here, WDYT @aslakknutsen ?
opendatahub-operator/pkg/deploy/deploy.go
Lines 316 to 322 in 6711ab3
// Perform server-side apply | |
data, err := json.Marshal(obj) | |
if err != nil { | |
return err | |
} | |
return cli.Patch(ctx, found, client.RawPatch(types.ApplyPatchType, data), client.ForceOwnership, client.FieldOwner(owner.GetName())) |
@@ -123,4 +124,29 @@ metadata: | |||
Expect(realNs.Name).To(Equal("real-file-test-ns")) | |||
}) | |||
|
|||
It("should set the managed annotation when feature is managed", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need such a test scenario. It focuses on the "how" part (implementation detail) whereas we should be testing the behavior (if it's actually managed).
I was thinking - how about converting the entire resources_int_test.go
test cases to be feature-driven with Managed
being invoked or not? This is what we need to test here - and also scenario when we do not call .Managed()
explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
96c7980 reworked!
Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aslakknutsen, zdtsw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest-required |
a679cd3
into
opendatahub-io:incubation
#974) * add reconiliation option to feature+createResource * fix typo in test * extract markAsManaged Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com> * remove dead const * re-add fixture, rework MarkAsManaged defn * refactor/rename ApplyResources * rework testing, unexport applyResources * error out faster in applyResources --------- Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com>
opendatahub-io#974) * add reconiliation option to feature+createResource * fix typo in test * extract markAsManaged Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com> * remove dead const * re-add fixture, rework MarkAsManaged defn * refactor/rename ApplyResources * rework testing, unexport applyResources * error out faster in applyResources --------- Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com>
https://issues.redhat.com/browse/RHOAIENG-5483
Description
Previously, every manifest/template (which is not a patch) was applied only once and left without reconciliation when Manifests are created/applied by our
Feature
s.This PR aims to give users more control over when if resources are reconciled, allowing for them to mark resources as those that should be updated on operator reconcile by marking them with the annotation:
"opendatahub.io/managed": "true"
for those that should be reconciled. If the annotation is not present or is set to"false"
we do not reconcile, maintaining previous behavior.The PR also provides another more convenient way to mark that all
Manifest
s part of aFeature
should be annotated and reconciled with the newManaged()
part of the builder. Simply addManaged().
to the call chain of a builder to enforce that all resources created by theFeature
will be updated on reconcile. Like so:How Has This Been Tested?
See the tests added both testing the behavior of
CreateResource()
as well asManaged()
.Also tested manually with an operator build that contained some dummy configmap manifests, one with the annotation as true and one without the annotation, and checked that after editing each and triggering a reconcile, the managed configmap was reconciled to its previous state and the non-managed configmap still contained my changes.
Merge criteria: