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

🐛 Remove old ns when klusterlet ns is changed #442

Merged

Conversation

qiujian16
Copy link
Member

Summary

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from xuezhaojun and zhujian7 April 25, 2024 07:52
@qiujian16
Copy link
Member Author

/hold

@qiujian16
Copy link
Member Author

/assign @elgnay

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

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

Project coverage is 62.57%. Comparing base (bcbe4d2) to head (d9efaa9).
Report is 37 commits behind head on main.

Files Patch % Lines
...terletcontroller/klusterlet_namespace_reconcile.go 70.00% 4 Missing and 2 partials ⚠️
...lers/klusterletcontroller/klusterlet_controller.go 72.22% 4 Missing and 1 partial ⚠️
...usterletcontroller/klusterlet_managed_reconcile.go 71.42% 1 Missing and 1 partial ⚠️
...controllers/klusterletcontroller/client_builder.go 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #442      +/-   ##
==========================================
+ Coverage   61.54%   62.57%   +1.02%     
==========================================
  Files         133      135       +2     
  Lines       14078    11472    -2606     
==========================================
- Hits         8665     7179    -1486     
+ Misses       4664     3528    -1136     
- Partials      749      765      +16     
Flag Coverage Δ
unit 62.57% <74.54%> (+1.02%) ⬆️

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.

@qiujian16 qiujian16 force-pushed the ns-remove branch 2 times, most recently from e68430f to b0f2c8b Compare April 25, 2024 09:05
Copy link
Contributor

openshift-ci bot commented Apr 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16

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

@qiujian16 qiujian16 force-pushed the ns-remove branch 2 times, most recently from 4cdcb28 to 3a9ad95 Compare April 26, 2024 07:55
Signed-off-by: Jian Qiu <jqiu@redhat.com>
if ns.Name == config.KlusterletNamespace || ns.Name == config.KlusterletNamespace+"-addon" {
continue
}
if err := r.managedClusterClients.kubeClient.CoreV1().Namespaces().Delete(
Copy link
Member

Choose a reason for hiding this comment

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

will the old addon namespaces be deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Member Author

Choose a reason for hiding this comment

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

but we should not delete old addon ns actually.

namespace string, recorder events.Recorder) error {
if err := ensureAgentNamespace(ctx, kubeClient, namespace, recorder); err != nil {
if err := ensureAgentNamespace(ctx, kubeClient, namespace, map[string]string{
Copy link
Member

Choose a reason for hiding this comment

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

I do not recommend calling the ensureAgentNamespace in ensureKlusterletNamespace func, since agent namespace is the namespace that klusterlet-agent runs in, it is on the manamegent cluster for hosted mode.

can we change the current ensureAgentNamespace to ensureNamespace, so here let the ensureKlusterletNamespace call the ensureNamespace func, and we add another ensureAgentNamespace which wraps the ensureNamespace.

  • managed_reconcile -> ensureKlusterletNamespace -> ensureNamespace
  • management_reconcile -> ensureAgentNamespace -> ensureNamespace

and after the separation, not sure if we only need to pass the labels for ensureKlusterletNamespace based on the current implemation?

Copy link
Member Author

Choose a reason for hiding this comment

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

refactored

return err
}, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed())

By("old namespace should be removed")
Copy link
Member

Choose a reason for hiding this comment

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

A little confusing here, in the klusterlet_namespace_reconcile, we check only after the new klusterlet status is available, we delete the old ns. but here the old ns is removed, while the new CSR is still not approved?

Copy link
Member Author

Choose a reason for hiding this comment

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

we check if it is applied

ctx context.Context,
klusterlet *operatorapiv1.Klusterlet,
config klusterletConfig) (*operatorapiv1.Klusterlet, reconcileState, error) {
if !meta.IsStatusConditionTrue(klusterlet.Status.Conditions, operatorapiv1.ConditionKlusterletApplied) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also check the observed generation in the klusterlet status?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Signed-off-by: Jian Qiu <jqiu@redhat.com>
@zhujian7
Copy link
Member

zhujian7 commented May 6, 2024

LGTM

@zhujian7
Copy link
Member

zhujian7 commented May 6, 2024

/lgtm

@qiujian16
Copy link
Member Author

/unhold

@openshift-merge-bot openshift-merge-bot bot merged commit 5fc1dbd into open-cluster-management-io:main May 6, 2024
14 checks passed
@qiujian16 qiujian16 deleted the ns-remove branch May 6, 2024 03: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.

3 participants