@@ -12,14 +12,12 @@ import (
12
12
. "github.com/onsi/ginkgo/v2"
13
13
. "github.com/onsi/gomega"
14
14
appsv1 "k8s.io/api/apps/v1"
15
- corev1 "k8s.io/api/core/v1"
16
- "k8s.io/apimachinery/pkg/api/errors"
17
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18
16
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
19
17
"sigs.k8s.io/cluster-api/test/framework"
20
- "sigs.k8s.io/controller-runtime/pkg/client"
21
18
22
19
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
20
+ "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/utils"
23
21
)
24
22
25
23
const clusterAutoscalerPrefix = "cluster-autoscaler-"
@@ -42,23 +40,17 @@ func WaitForClusterAutoscalerToBeReadyInWorkloadCluster(
42
40
return
43
41
}
44
42
45
- // Only check for ClusterAutoscaler if the cluster is self-managed. Check this by checking if the kubeconfig
46
- // exists in the workload cluster itself.
43
+ // Only check for ClusterAutoscaler if the cluster is self-managed.
44
+ // ManagementCluster function will return a nil managementCluster if workloadClusterClient
45
+ // is not a self-managed cluster.
47
46
workloadClusterClient := input .ClusterProxy .GetWorkloadCluster (
48
47
ctx , input .WorkloadCluster .Namespace , input .WorkloadCluster .Name ,
49
48
).GetClient ()
50
- err := workloadClusterClient .Get (
51
- ctx ,
52
- client.ObjectKey {
53
- Namespace : input .WorkloadCluster .Namespace ,
54
- Name : input .WorkloadCluster .Name + "-kubeconfig" ,
55
- },
56
- & corev1.Secret {},
57
- )
58
- if err != nil && errors .IsNotFound (err ) {
49
+ managementCluster , err := utils .ManagementCluster (ctx , workloadClusterClient )
50
+ Expect (err ).NotTo (HaveOccurred ())
51
+ if managementCluster == nil {
59
52
return
60
53
}
61
- Expect (err ).NotTo (HaveOccurred ())
62
54
63
55
switch input .ClusterAutoscaler .Strategy {
64
56
case v1alpha1 .AddonStrategyClusterResourceSet :
0 commit comments