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

✨ sync between ManagedCluster and cluster inventory API #615

Conversation

haoqing0110
Copy link
Member

@haoqing0110 haoqing0110 commented Sep 10, 2024

Summary

Related issue(s)

#247

@haoqing0110 haoqing0110 changed the title sync between ManagedCluster and cluster inventory API ✨ sync between ManagedCluster and cluster inventory API Sep 10, 2024
@haoqing0110
Copy link
Member Author

/hold more UT to add

@haoqing0110
Copy link
Member Author

/assign @qiujian16
Could you help to review if pkg/registration/hub/clusterprofile/controller.go contains all the necessary fields we want to sync from ManagedCluster today?


// sync status.properties
cpProperties := []cpv1alpha1.Property{}
for k, v := range managedCluster.GetLabels() {
Copy link
Member

Choose a reason for hiding this comment

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

should not get labels, but clusterclaims in the 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.

fixed.

if modified {
_, err := c.patcher.PatchLabelAnnotations(ctx, newClusterProfile, newClusterProfile.ObjectMeta, clusterProfile.ObjectMeta)
if err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

directly return here, we can update status in the next loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 67.54386% with 37 lines in your changes missing coverage. Please review.

Project coverage is 64.08%. Comparing base (43c3500) to head (0b204cb).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/registration/hub/clusterprofile/controller.go 77.64% 16 Missing and 3 partials ⚠️
pkg/registration/hub/manager.go 38.88% 8 Missing and 3 partials ⚠️
...rmanagercontroller/clustermanager_hub_reconcile.go 33.33% 2 Missing and 2 partials ⚠️
...rmanagercontroller/clustermanager_crd_reconcile.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #615      +/-   ##
==========================================
+ Coverage   64.07%   64.08%   +0.01%     
==========================================
  Files         181      182       +1     
  Lines       14166    14277     +111     
==========================================
+ Hits         9077     9150      +73     
- Misses       4186     4214      +28     
- Partials      903      913      +10     
Flag Coverage Δ
unit 64.08% <67.54%> (+0.01%) ⬆️

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.

@@ -49,6 +49,7 @@ var (
"cluster-manager/hub/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml",
"cluster-manager/hub/0000_03_clusters.open-cluster-management.io_placementdecisions.crd.yaml",
"cluster-manager/hub/0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml",
"cluster-manager/hub/0000_00_multicluster.x-k8s.io_clusterprofiles.crd.yaml",
Copy link
Member

Choose a reason for hiding this comment

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

we should not install this crd when feature is diabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

The concern is whether should we remove the crd (together with all the crs) when disabled, any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

we do not need to remove when disable, but since the feature is disabled by default, I do not want the crd is surprisingly created.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

// CRD resource files to clean
hubDeployCRDResources := hubCRDResourceFiles

// Include the ClusterProfile CRD in case it was installed, since the CRD will not be
Copy link
Member

Choose a reason for hiding this comment

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

the comment said the crd will not be removed, so why should we clean up it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ClusterProfile crd is not removed when featuregates disable, but will be cleaned when ClusterManager is deleting, the behavior of disable and clean (except install) are the same as other crds.
But this is a good question since ClusterProfile CRD might be used by other project, might need to leave it.

Copy link
Member

Choose a reason for hiding this comment

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

yes let's just leave it.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@qiujian16
Copy link
Member

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 14, 2024
Copy link
Contributor

openshift-ci bot commented Oct 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haoqing0110, 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

@haoqing0110
Copy link
Member Author

/unhold

@openshift-merge-bot openshift-merge-bot bot merged commit d9ab252 into open-cluster-management-io:main Oct 15, 2024
15 checks passed
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