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

✨ Cluster decorator interface #759

Conversation

jaswalkiranavtar
Copy link
Contributor

Summary

Adding ManagedCluster annotations using a Decorator

Related issue(s)

Fixes #

qiujian16 and others added 2 commits December 10, 2024 11:18
And refactor creating to controller to call decorators

Signed-off-by: Jian Qiu <jqiu@redhat.com>
Signed-off-by: Gaurav Jaswal <jaswalkiranavtar@gmail.com>
@openshift-ci openshift-ci bot requested review from ldpliu and zhujian7 December 10, 2024 23:09
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 68.33333% with 19 lines in your changes missing coverage. Please review.

Project coverage is 63.65%. Comparing base (ddc5024) to head (148bf4b).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...stration/spoke/registration/creating_controller.go 78.37% 6 Missing and 2 partials ⚠️
pkg/registration/register/aws_irsa/aws_irsa.go 41.66% 7 Missing ⚠️
pkg/registration/register/csr/csr.go 0.00% 2 Missing ⚠️
pkg/registration/spoke/spokeagent.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #759      +/-   ##
==========================================
+ Coverage   63.58%   63.65%   +0.06%     
==========================================
  Files         187      187              
  Lines       17989    17999      +10     
==========================================
+ Hits        11439    11457      +18     
+ Misses       5601     5594       -7     
+ Partials      949      948       -1     
Flag Coverage Δ
unit 63.65% <68.33%> (+0.06%) ⬆️

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.

Copy link
Member

@mikeshng mikeshng left a comment

Choose a reason for hiding this comment

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

Left some questions. Leaving it to @qiujian16 and other registration maintainers.

Part of #514

@@ -71,6 +71,9 @@ type RegisterDriver interface {
// InformerHandler returns informer of the related object. If no object needs to be watched, the func could
// return nil, nil.
InformerHandler(option any) (cache.SharedIndexInformer, factory.EventFilterFunc)

// ManagedClusterDecorator is to change managed cluster metadata or spec during registration process.
ManagedClusterDecorator(managedClusterArn string, managedClusterRoleSuffix string) ManagedClusterDecorator
Copy link
Member

Choose a reason for hiding this comment

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

in the interface level, the input should not be

managedClusterArn string, managedClusterRoleSuffix string

since other driver does not know about this, and if we have another driver later that needs other input, this would need to change the signature of the interface.

The interface should be the same as ManagedClusterDecorator, which is only to mutate the managedcluster.
The managedClusterArn and managedClusterRoleSuffix could be put into the driver at the NewDriver part.

}
var registrationOption = o.registrationOption
if registrationOption.RegistrationAuth == AwsIrsaAuthType {
registerDriver = awsIrsa.NewAWSIRSADriver()
Copy link
Member

Choose a reason for hiding this comment

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

let's change this to

awsIrsa.NewAWSIRSADriver(o.registrationOption.ManagedClusterArn, o.registrationOption.ManagedClusterRoleSuffix)

so we do not need call decorator with these parameter.

Signed-off-by: Gaurav Jaswal <jaswalkiranavtar@gmail.com>
@@ -230,7 +230,7 @@ func TestIsHubKubeConfigValidFunc(t *testing.T) {
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
driver := NewAWSIRSADriver()
driver := NewAWSIRSADriver("", "")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please ignore this one, we are planning to fix this in future, when we implement the completion of joining, Did this now to resolve a compilation error.

@qiujian16
Copy link
Member

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Dec 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

@openshift-merge-bot openshift-merge-bot bot merged commit b170f3a into open-cluster-management-io:main Dec 11, 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.

3 participants