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

🐛 fix gc controller not handle empty cluster #812

Merged

Conversation

zhiweiyin318
Copy link
Member

Summary

the gc controller returned when cluster is empty, and the work rolebinding is left over.
this PR will handle the case that cluster is empty in gc controller.

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from elgnay and ldpliu January 19, 2025 15:17
Copy link

codecov bot commented Jan 19, 2025

Codecov Report

Attention: Patch coverage is 62.71186% with 22 lines in your changes missing coverage. Please review.

Project coverage is 63.80%. Comparing base (f03b3f7) to head (514e6da).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/registration/hub/gc/controller.go 45.83% 8 Missing and 5 partials ⚠️
pkg/registration/hub/gc/gc_cluster_rbac.go 35.71% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #812      +/-   ##
==========================================
- Coverage   63.84%   63.80%   -0.04%     
==========================================
  Files         193      193              
  Lines       18674    18667       -7     
==========================================
- Hits        11922    11911      -11     
- Misses       5772     5774       +2     
- Partials      980      982       +2     
Flag Coverage Δ
unit 63.80% <62.71%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhiweiyin318
Copy link
Member Author

/assign @qiujian16
/assign @zhujian7
/assign @elgnay

pkg/registration/hub/gc/controller.go Show resolved Hide resolved
pkg/registration/hub/gc/controller.go Outdated Show resolved Hide resolved
pkg/registration/hub/gc/controller.go Outdated Show resolved Hide resolved
@zhiweiyin318 zhiweiyin318 force-pushed the fix-gc branch 3 times, most recently from 7476293 to 218ce22 Compare January 20, 2025 14:49
Copy link
Member

@qiujian16 qiujian16 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 in general. Can we add an integration test?

@zhiweiyin318 zhiweiyin318 force-pushed the fix-gc branch 4 times, most recently from a488232 to 43bcd65 Compare January 21, 2025 07:16
@zhiweiyin318
Copy link
Member Author

looks good in general. Can we add an integration test?

@qiujian16 added a case that cluster is gone in the gc integration tests.

@qiujian16
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 22, 2025
var copyCluster *clusterv1.ManagedCluster
if cluster != nil {
if cluster.DeletionTimestamp.IsZero() {
_, err = r.clusterPatcher.AddFinalizer(ctx, cluster, clusterv1.ManagedClusterFinalizer)
Copy link
Member

Choose a reason for hiding this comment

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

with this finalizer, why is it possible the cluster was deleted before resource cleanup?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a case that will remove the finalizer after delete the rbac when gc feature gate is disable, but the finalizer of work rolebinding can only be removed after all works are deleted. in this case the cluster may be gone.

@elgnay
Copy link
Contributor

elgnay commented Jan 22, 2025

/lgtm

@qiujian16
Copy link
Member

/approve

Copy link
Contributor

openshift-ci bot commented Jan 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, zhiweiyin318

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

@openshift-merge-bot openshift-merge-bot bot merged commit b6c2a84 into open-cluster-management-io:main Jan 23, 2025
15 checks passed
@zhiweiyin318 zhiweiyin318 deleted the fix-gc branch January 23, 2025 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants