Skip to content

Commit 374da7c

Browse files
jeffw17jaswalkiranavtar
authored andcommitted
Add changes to clusteradm accept to disable csr update based on annotation on ManagedCluster
Signed-off-by: “Jeffrey <[email protected]> Signed-off-by: Gaurav Jaswal <[email protected]>
1 parent a756dd6 commit 374da7c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/cmd/accept/exec.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,24 @@ func (o *Options) runWithClient(kubeClient *kubernetes.Clientset, clusterClient
9494
}
9595

9696
func (o *Options) accept(kubeClient *kubernetes.Clientset, clusterClient *clusterclientset.Clientset, clusterName string, waitMode bool) (bool, error) {
97-
approved, err := o.approveCSR(kubeClient, clusterName, waitMode)
97+
managedCluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.TODO(),
98+
clusterName,
99+
metav1.GetOptions{})
98100
if err != nil {
99-
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
101+
return false, fmt.Errorf("fail to get managedcluster %s: %v", clusterName, err)
102+
}
103+
_, hasEksArn := managedCluster.Annotations["agent.open-cluster-management.io/managed-cluster-arn"]
104+
105+
var approved bool
106+
if !hasEksArn {
107+
approved, err = o.approveCSR(kubeClient, clusterName, waitMode)
108+
if err != nil {
109+
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
110+
}
111+
} else {
112+
approved = true
100113
}
114+
101115
err = o.updateManagedCluster(clusterClient, clusterName)
102116
if err != nil {
103117
return approved, err

0 commit comments

Comments
 (0)