-
Notifications
You must be signed in to change notification settings - Fork 69
KUBESAW-264: Implement TierTemplateRevision cleanup controller #1153
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
KUBESAW-264: Implement TierTemplateRevision cleanup controller #1153
Conversation
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
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.
Great work! 🚀
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Show resolved
Hide resolved
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.
Overall looks good, I still need to take a better look at the unit tests 👍
Nice job 🚀
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
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.
Great job ! Mostly LGTM.
I have only few last minor comments.
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
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.
Great job 🚀
Thanks for addressing my comments and for the additional changes 🙏
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
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.
Looks good
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller_test.go
Outdated
Show resolved
Hide resolved
if errors.IsNotFound(err) { | ||
// if there is no related nstemplate tier, we can delete the TTR directly | ||
return reconcile.Result{}, r.deleteTTR(ctx, ttr) | ||
} |
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.
Btw, if you added a watcher on NSTemplateTier CRD with a predicate that would allow deletion events only, then you could remove the TTR-specific cleanup logic from the e2e tests.
Can be done as separate PR
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.
You meant the watcher in this controller itselt?
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
// Error reading the object - requeue the request. | ||
return reconcile.Result{}, fmt.Errorf("unable to get the current TierTemplateRevision: %w", err) | ||
} | ||
|
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.
There should be a check for a non-nil ttr.DeletionTimeStamp
- am I right in assuming we don't want to continue the reconciliation if we detect the TTR is already in the process of being deleted?
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.
good catch, but there is no finalizer which means that it should be deleted immediately.
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.
and if we want to check if it's not being deleted, then we should use util.IsBeingDeleted(ttr)
instead.
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.
okay just curious, if we don't have finalizers, then any particular reason on why we should still check isBeingDeleted
, there won't be any delay as per my understanding, may be i missed some case ?
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.
Usually, if you detect the resource is being deleted, you just stop the reconcile by returning early without an error. If there are finalizers, you first do the clean up logic, remove the finalizer and then return, again not performing the "normal" reconciliation logic.
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.
@metlos I have updated it now PTAL.
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.
@metlos the point was that if there is no finalizer added, then as soon as the resource has the deletion timestamp set, then it should be immediately deleted.
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Outdated
Show resolved
Hide resolved
controllers/nstemplatetierrevisioncleanup/nstemplatetier_revision_cleanup_controller.go
Show resolved
Hide resolved
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@fbm3307: No presubmit jobs available for codeready-toolchain/host-operator@master In response to this:
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-sigs/prow repository. |
/test e2e looks unrelated flaky test |
@fbm3307: No presubmit jobs available for codeready-toolchain/host-operator@master In response to this:
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-sigs/prow repository. |
/test e2e |
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fbm3307, MatousJobanek, metlos, mfrancisc 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 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1153 +/- ##
==========================================
+ Coverage 79.68% 79.73% +0.04%
==========================================
Files 82 83 +1
Lines 8245 8333 +88
==========================================
+ Hits 6570 6644 +74
- Misses 1479 1492 +13
- Partials 196 197 +1
🚀 New features to boost your workflow:
|
This PR is to create a cleanup controller for TierTemplateRevision CRs so that it deletes all the TierTemplateRevisions CRs that are not used by any Space