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

✨ Add changes to clusteradm accept to disable csr update based on annotation on ManagedCluster #468

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions pkg/cmd/accept/exec.go
Original file line number Diff line number Diff line change
@@ -94,10 +94,27 @@ func (o *Options) runWithClient(kubeClient *kubernetes.Clientset, clusterClient
}

func (o *Options) accept(kubeClient *kubernetes.Clientset, clusterClient *clusterclientset.Clientset, clusterName string, waitMode bool) (bool, error) {
approved, err := o.approveCSR(kubeClient, clusterName, waitMode)
managedCluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.TODO(),
clusterName,
metav1.GetOptions{})
if err != nil {
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
return false, fmt.Errorf("fail to get managedcluster %s: %v", clusterName, err)
}
// when a managed cluster registers with hub using awsirsa registration-auth, it will add this annotation
// to ManagedCluster resource, presense of which is used to decide the requested authentication type.
// awrirsa authentication doesn't create CSR on hub, hence there is nothing to approve
_, hasEksArn := managedCluster.Annotations["agent.open-cluster-management.io/managed-cluster-arn"]
Copy link
Member

Choose a reason for hiding this comment

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

please add a comment here.

Copy link
Member

Choose a reason for hiding this comment

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

Done. Does it look ok? Will sign the commit tomorrow.


var approved bool
if !hasEksArn {
approved, err = o.approveCSR(kubeClient, clusterName, waitMode)
if err != nil {
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
}
} else {
approved = true
}

err = o.updateManagedCluster(clusterClient, clusterName)
if err != nil {
return approved, err