@@ -94,10 +94,27 @@ func (o *Options) runWithClient(kubeClient *kubernetes.Clientset, clusterClient
94
94
}
95
95
96
96
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 {})
98
100
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
+ // when a managed cluster registers with hub using awsirsa registration-auth, it will add this annotation
104
+ // to ManagedCluster resource, presense of which is used to decide the requested authentication type.
105
+ // awrirsa authentication doesn't create CSR on hub, hence there is nothing to approve
106
+ _ , hasEksArn := managedCluster .Annotations ["agent.open-cluster-management.io/managed-cluster-arn" ]
107
+
108
+ var approved bool
109
+ if ! hasEksArn {
110
+ approved , err = o .approveCSR (kubeClient , clusterName , waitMode )
111
+ if err != nil {
112
+ return approved , fmt .Errorf ("fail to approve the csr for cluster %s: %v" , clusterName , err )
113
+ }
114
+ } else {
115
+ approved = true
100
116
}
117
+
101
118
err = o .updateManagedCluster (clusterClient , clusterName )
102
119
if err != nil {
103
120
return approved , err
0 commit comments