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

✨ Implement Reconcile mode for ClusterResourceSet #7497

Merged
merged 22 commits into from
Feb 19, 2023

Conversation

g-gaston
Copy link
Contributor

@g-gaston g-gaston commented Nov 4, 2022

What this PR does / why we need it:

Implements Reconcile mode for ClusterResourceSet's, introduced by proposal #6555

Fixes: #4807

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 4, 2022
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 4, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @g-gaston. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 4, 2022
Copy link

@jonathanmeier5 jonathanmeier5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all sounds reasonable to me. Looking forward to using this new reconciliation strategy.

My understanding of this change is that we are adding a Reconcile resolution strategy to the Cluster Resource Set CRD. The new Reconcile strategy will update existing Secret and ConfigMap objects contents when they change in the CRS.

The bulk of this PRs changes business logic changes appear to come from the ApplyClusterResourceSet function. Some of its business logic is refactored into clusterresourceset_scope.go, where hashing and other utility functions are abstracted into the ResourceReconcileScope object.

Outside of the unit tests, how did you test this implementation?

@g-gaston
Copy link
Contributor Author

g-gaston commented Nov 8, 2022

This all sounds reasonable to me. Looking forward to using this new reconciliation strategy.

My understanding of this change is that we are adding a Reconcile resolution strategy to the Cluster Resource Set CRD. The new Reconcile strategy will update existing Secret and ConfigMap objects contents when they change in the CRS.

The bulk of this PRs changes business logic changes appear to come from the ApplyClusterResourceSet function. Some of its business logic is refactored into clusterresourceset_scope.go, where hashing and other utility functions are abstracted into the ResourceReconcileScope object.

Outside of the unit tests, how did you test this implementation?

The tests in clusterresourceset_controller_test.go are integration tests, then run the controller connected to a real etcd and api server (using envtest). So those are a bit more robust than just unit tests, the test the reconciliation logic end to end (or almost, since there is no a real workload cluster).

I also tested this manually running some capd clusters with tilt.

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few nits, didn't get to the controllers folder yet

@sbueringer
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 28, 2022
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!!

Overall looks good to me, although I have to say I don't have a lot of experience with the CRS code base.

Would be nice to get some reviews from the other folks interested in this feature.

g-gaston and others added 2 commits December 5, 2022 17:35
Co-authored-by: Stefan Büringer <4662360+sbueringer@users.noreply.github.com>
@g-gaston g-gaston requested review from sbueringer and removed request for stmcginnis, CecileRobertMichon and sbueringer December 5, 2022 23:50
Comment on lines +158 to +159
// The create call is idempotent, so if the object already exists
// then do not consider it to be an error.
Copy link
Member

@sbueringer sbueringer Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup Fabrizio is right.

There are two usages of createUnstructured. l.127 and l.168. In l.168 we check for already exists in l.127 we don't.

Or is that intentional? (that we ignore already exists in ApplyOnce and we surface it in Reconcile?)

g-gaston and others added 4 commits January 25, 2023 16:45
Co-authored-by: Stefan Büringer <4662360+sbueringer@users.noreply.github.com>
Co-authored-by: Fabrizio Pandini <fabrizio.pandini@gmail.com>
@sbueringer
Copy link
Member

/retest

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits, otherwise lgtm from my side (+ linter)

g.Expect(env.Update(ctx, testCluster)).To(Succeed())

t.Log("Updating the test config map with the missing namespace resource")
missingNamespace := randomNamespaceForTest(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the linter is complaining about the way you're generating the name anyway. WDYT about just using something like this?

Suggested change
missingNamespace := randomNamespaceForTest(t)
missingNamespace := fmt.Sprintf("clusterresourceset-apply-once-%s", util.RandomString(6))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it if you prefer but I thought it was a useful function to have.

btw fixed the linter

Copy link
Member

@sbueringer sbueringer Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for me to keep just seems more complicated to have our own random func here vs. using the util that we use in a lot of other places

(usually we also use a prefix for the namespace which roughly identifies the test, just makes it easier to map resources to tests when debugging envtest based tests)

Up to you

g-gaston and others added 3 commits February 13, 2023 12:21
Co-authored-by: Stefan Büringer <4662360+sbueringer@users.noreply.github.com>
…t.go typo

Co-authored-by: Stefan Büringer <4662360+sbueringer@users.noreply.github.com>
@g-gaston g-gaston requested review from sbueringer and removed request for fabriziopandini February 13, 2023 19:37
@sbueringer
Copy link
Member

Thank you very much!

/lgtm

/assign @fabriziopandini

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 14, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: cd1d00bb36ba52dc2f56564cb2ba15c199e378d7

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 19, 2023
@k8s-ci-robot k8s-ci-robot merged commit 5e96566 into kubernetes-sigs:main Feb 19, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.4 milestone Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Continuous ClusterResourceSetStrategy
8 participants