-
Notifications
You must be signed in to change notification settings - Fork 107
✨ Enable sync labels for clustermanager operator and registration controller #1021
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
base: main
Are you sure you want to change the base?
✨ Enable sync labels for clustermanager operator and registration controller #1021
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jeffw17 The full list of commands accepted by this bot can be found 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 @@
## main #1021 +/- ##
==========================================
- Coverage 64.25% 64.02% -0.24%
==========================================
Files 195 196 +1
Lines 19118 19362 +244
==========================================
+ Hits 12285 12397 +112
- Misses 5823 5933 +110
- Partials 1010 1032 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pkg/registration/helpers/helpers.go
Outdated
@@ -176,3 +179,21 @@ func IsCSRSupported(nativeClient kubernetes.Interface) (bool, bool, error) { | |||
} | |||
return v1CSRSupported, v1beta1CSRSupported, nil | |||
} | |||
|
|||
func ParseLabels(labels string) map[string]string { |
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 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.
do we still need this func?
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.
Removed it
...r/operators/clustermanager/controllers/clustermanagercontroller/clustermanager_controller.go
Outdated
Show resolved
Hide resolved
@@ -136,6 +136,11 @@ func (c *runtimeReconcile) reconcile(ctx context.Context, cm *operatorapiv1.Clus | |||
} | |||
} | |||
|
|||
if cm.Labels != nil { |
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.
why do we need this again, I think config has been set on the controller already.
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.
We want to sync the labels continuously. In case the labels are changed on the clustermanager, the new labels should be reflected.
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.
hrm I do not think it will happen in reconcile, the cm is passed from the controller and it has been updated already, this will not be changed in the reconcile loop.
@@ -89,6 +90,8 @@ func (m *HubManagerOptions) AddFlags(fs *pflag.FlagSet) { | |||
fs.StringSliceVar(&m.AutoApprovedARNPatterns, "auto-approved-arn-patterns", m.AutoApprovedARNPatterns, | |||
"A list of AWS EKS ARN patterns such that an EKS cluster will be auto approved if its ARN matches with any of the patterns") | |||
fs.StringSliceVar(&m.AwsResourceTags, "aws-resource-tags", m.AwsResourceTags, "A list of tags to apply to AWS resources created through the OCM controllers") | |||
fs.StringVar(&m.Labels, "labels", m.Labels, |
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.
It is better to set it as fs.StringSliceVar, and convert it to map in complete.
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.
If we use StringSliceVar which returns m.Labels as a []string then we won't be able to leverage generate.ParseLabels() as it expects a string to convert to map.
Signed-off-by: Amrutha <[email protected]>
…ion test Signed-off-by: Jeffrey Wong <[email protected]>
…ble and also add labels to rbac manifests if present.
Signed-off-by: Amrutha <[email protected]>
Signed-off-by: Amrutha <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
857d79d
to
5efb103
Compare
go.mod
Outdated
k8s.io/client-go v0.32.4 | ||
k8s.io/component-base v0.32.4 | ||
k8s.io/client-go v0.33.1 | ||
k8s.io/component-base v0.33.1 |
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.
please do not upgrade the library
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
Signed-off-by: Jeffrey Wong <[email protected]>
b802ec7
to
ce7b700
Compare
Signed-off-by: Jeffrey Wong <[email protected]>
ce7b700
to
a5c33be
Compare
eventuallyInterval = 1 // seconds | ||
eventuallyTimeout = 30 // seconds | ||
eventuallyInterval = 1 // seconds | ||
testCustomLabel = "custom-label" |
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.
this should not be set as global variable. It will be really hard to maintain. You should consider stop the existing hub, customize the option and restart the hub in the specific test. Example like this https://github.com/open-cluster-management-io/ocm/blob/main/test/integration/registration/spokecluster_aws_joining_test.go#L32-L47
@@ -129,6 +129,11 @@ var _ = ginkgo.BeforeSuite(func() { | |||
_, err = operatorClient.OperatorV1().ClusterManagers().Create(context.Background(), &operatorapiv1.ClusterManager{ | |||
ObjectMeta: metav1.ObjectMeta{ | |||
Name: clusterManagerName, | |||
Labels: map[string]string{ | |||
"app": "clustermanager", |
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.
same here, consider a test that update the clustermanager, and check that the label is updated on the resource instead of setting it globally.
41a2367
to
74e01d5
Compare
…abels during the test Signed-off-by: suvaanshkumar <[email protected]>
74e01d5
to
aa86a23
Compare
Summary
Previously, there was a feature implemented where the klusterlet resources have labels passed down to resources created indirectly by the controllers. This feature was not implemented in the clustermanager side. For example, the operator goes ahead and create the various deployments on the open-cluster-management-hub namespace and those deployments will now have the same labels as the operator. As such, the changes in this PR implements this feature. The feature in this PR however only applies to the cluster-manager operator and the registration-controller. In a future date, we will implement the same feature for the other controllers (i.e. placement-controller, work-controller, etc.). To enable this feature, in the helm charts, you can set enableSyncLabels to true or, in clusteradm commands, you can add the --enable-sync-labels=true flag.
Related issue(s)
#957
Fixes # 957