Skip to content

Commit

Permalink
Add changes to clusteradm accept to disable csr update based on annot…
Browse files Browse the repository at this point in the history
…ation on ManagedCluster

Signed-off-by: “Jeffrey <[email protected]>
  • Loading branch information
jeffw17 committed Jan 31, 2025
1 parent a756dd6 commit dfbcabc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/cmd/accept/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,24 @@ 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 managed cluster")
}
_, hasEksArn := managedCluster.Annotations["agent.open-cluster-management.io/managed-cluster-arn"]

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 = hasEksArn
}

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

0 comments on commit dfbcabc

Please sign in to comment.