Skip to content

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

Merged

Conversation

fbm3307
Copy link
Contributor

@fbm3307 fbm3307 commented Mar 7, 2025

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

Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
fbm3307 added 6 commits March 7, 2025 15:44
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>
Copy link
Contributor

@rsoaresd rsoaresd left a comment

Choose a reason for hiding this comment

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

Great work! 🚀

Copy link
Contributor

@mfrancisc mfrancisc left a 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 🚀

fbm3307 added 2 commits March 11, 2025 12:16
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Copy link
Contributor

@mfrancisc mfrancisc 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 ! Mostly LGTM.

I have only few last minor comments.

Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@fbm3307 fbm3307 requested a review from mfrancisc March 13, 2025 13:04
Copy link
Contributor

@mfrancisc mfrancisc 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 🚀

Thanks for addressing my comments and for the additional changes 🙏

Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@fbm3307 fbm3307 requested a review from MatousJobanek March 13, 2025 16:04
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@fbm3307 fbm3307 requested a review from MatousJobanek March 13, 2025 16:40
Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Looks good

Comment on lines +71 to +74
if errors.IsNotFound(err) {
// if there is no related nstemplate tier, we can delete the TTR directly
return reconcile.Result{}, r.deleteTTR(ctx, ttr)
}
Copy link
Contributor

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

Copy link
Contributor Author

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?

// Error reading the object - requeue the request.
return reconcile.Result{}, fmt.Errorf("unable to get the current TierTemplateRevision: %w", err)
}

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

metlos and others added 3 commits March 14, 2025 13:34
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@fbm3307 fbm3307 requested a review from metlos March 18, 2025 05:38
Copy link

openshift-ci bot commented Mar 18, 2025

@fbm3307: No presubmit jobs available for codeready-toolchain/host-operator@master

In response to this:

/test e2e, looks like a flaky test

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.

@fbm3307
Copy link
Contributor Author

fbm3307 commented Mar 18, 2025

/test e2e

looks unrelated flaky test

Copy link

openshift-ci bot commented Mar 18, 2025

@fbm3307: No presubmit jobs available for codeready-toolchain/host-operator@master

In response to this:

/test e2e

looks unrelated flaky test

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.

@fbm3307
Copy link
Contributor Author

fbm3307 commented Mar 18, 2025

/test e2e

Copy link

Copy link

openshift-ci bot commented Mar 20, 2025

[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:
  • OWNERS [MatousJobanek,fbm3307,metlos,mfrancisc]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fbm3307 fbm3307 merged commit 825a78b into codeready-toolchain:master Mar 20, 2025
12 of 14 checks passed
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 84.09091% with 14 lines in your changes missing coverage. Please review.

Project coverage is 79.73%. Comparing base (13f3520) to head (f9ebadc).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...anup/nstemplatetier_revision_cleanup_controller.go 90.24% 7 Missing and 1 partial ⚠️
main.go 0.00% 6 Missing ⚠️
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     
Files with missing lines Coverage Δ
main.go 0.00% <0.00%> (ø)
...anup/nstemplatetier_revision_cleanup_controller.go 90.24% <90.24%> (ø)
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants