-
Notifications
You must be signed in to change notification settings - Fork 235
feat: Create applyset for use by instance reconciler #561
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
Conversation
38d805d
to
3b3280f
Compare
dadc8ca
to
fe7c298
Compare
245c976
to
472444e
Compare
Removed the callback mechanism completely.
Made the default behavior sequential.
We can improve on this. We can decide to do our own applyset implementation that has less LOC than a general applyset lib. PTAL again @a-hilaly |
@a-hilaly - Would you please take a look and approve ? |
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.
@barney-s Thank you for the persistence on this PR and addressing the feedback through multiple iterations. The work here is significant - implementing ApplySet for kro is a major architectural change and a positive one.
This is ready to merge. We can address any remaining items in follow-up PRs. Thank you again Barni! I've left some questions in the review below but these are minor compared to the overall value this brings.
gvr, | ||
processedRGD, | ||
r.clientSet, | ||
r.clientSet.RESTMapper(), |
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.
Note to team, we need to use more RESTMappers accross the code base.
@barney-s can you please squash the last 3 commits? |
da865e2
to
605ff0b
Compare
* https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/apply/ * https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/tree/master/applylib/applyset This is meant to be an illustration of what we are basing kro-applyset on.
* Applylib is inspired from: * kubectl pkg/cmd/apply/applyset.go * kubebuilder-declarative-pattern/applylib * Creating a simpler, self-contained version of the library that is purpose built for controllers. * Handle pruning and uses server-side apply * RGD controller changes * fix linter warnings for func defn lines being too long * Inject restMapper to be passed to instance controllers * Instance controller changes * When patching instance status, use retry-on-conflict loop * Since we apply all resolved resources, Join() errors across resources (apply/update errors) * Add changes to get restMapper and pass it on to applylib * Instance reconciler changes * Refactor reconcileInstance to use Applylib * Makefile * Add target to setup/install envtest * Setup envtest, kubebuilder assets for running e2e tests locally * Remove pkg/controller/instance/delta since we dont compute delta locally. We defer it to the server. * With SSA, we need to be careful about setting field manager * different reconciler paths use different managers * Introduce source-rgd labels to differenciate b/w parent rgd that creates an instance and the source rgd that defines the instance CRD * This is useful when we have an RGD creating and instance of another RG. Today we have a bug where the parent and the child reconcilers overwrite the labels. * (next steps) lifecycle support in applylib * redo externalRef as lifecycle hints * decorate lifecycle hint (create or update, no delete) ----------------------- Addressing review comments: * Move applyset/applylib -> pkg/applylib * Add more docs * Add a reference to the applyset KEP in comments * Add docs.go and interface docs * Improvements: * remove caching a json marshalled copy of obj * Remove name/namespace in PruneObject and instead derive it from object. Also change object type from runtime.Object to unstructured. * use fieldmanager config param to remove kro hardcoding in applyset * Aggregate pruneErrors and applyErrors into single Errors() * add recordPruneObject helper * switched from waitGroup to errgroup when collecting objects to prune across namespaces * take logr as a config in ApplySet. Added more logging in applyset. * use superset of namespaces and GKs we compute before apply for pruning * Add simple tests in the applyset pkg * use namespace-scoped resource interface when pruning * use force=True when applying in setManaged() * Removed un-necessary deepcopy in updateParentLabelsAndAnnotations * Add Unit tests to verify pruning and apply logic * Fix bugs in pruning logic that missed old namespaces and GKs * Remove callbacks and make code more procedural * Make pruning sequential by default * Refactors: * add RestMapper to the client-set * use Unstrucutred in ApplyableObject instead of interface and forcing it to be unstructured in code * minor restruction in processLoad() method * Refactor code that was using errors.Join and an array * Use ContainsFinalizer * Converting unstructured to PartialObjectMetadata for parent in applyset. * Cleanups: * Fix typos in comments, prints etc * Remove obseleted comments * Make the exported resources strutter less, applyset.ApplySet -> applyset.Set, NewApplySet -> New etc. * Fix captilaization for var names. Uid -> UID, ... * use consts for labelManager strings * remove pure formatting changes in unrelated files to minimize PR changeset Split out: * Remove pkg/metadata/finalizer.go changes and create a separate PR kubernetes-sigs#625 * move envtest makefile changes to kubernetes-sigs#636 * removing labeller changes and moving them to kubernetes-sigs#631 * Fix regression when removing labeller changes: `dynamic-controller Error syncing item, requeuing with rate limit {"item": {"NamespacedKey":"chainsaw-special-quail/test-instance","GVR":{"Group":"kro.run","Version":"v1alpha1","Resource":"checkinstancecreationsimpledeployments"}}, "error": "failed to setup instance: failed to set finalizer: error getting finalizers: .metadata.finalizers accessor error: [] is of the type []string, expected []interface{}"}`
Appreciate all the feedback and reviews.
Addressed most of the comments/Qs. |
Done. |
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.
🚀 🚀
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-hilaly, barney-s, jakobmoellerdev, matthchr 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 |
Nice work all 🚀 |
feat: Create applylib for use by instance reconciler
Applylib is inspired from:
RGD controller changes
Instance controller changes
resources (apply/update errors)
Instance reconciler changes
Makefile
With SSA, we need to be careful about setting field manager
creates an instance and the source rgd that defines the instance CRD
another RG. Today we have a bug where the parent and the child
reconcilers overwrite the labels.
(next steps) lifecycle support in applylib
Related:
Tests:
From #290
Passes the
Secret
test case.Passes other e2e tests: