Skip to content

Commit 59ba31e

Browse files
committed
Use openshift api to fetch control plane nodes schedulable info
Signed-off-by: Niranjan M.R <[email protected]>
1 parent e55127c commit 59ba31e

File tree

1 file changed

+11
-20
lines changed
  • test/e2e/performanceprofile/functests/utils/cluster

1 file changed

+11
-20
lines changed

test/e2e/performanceprofile/functests/utils/cluster/cluster.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package cluster
22

33
import (
44
"context"
5-
"fmt"
65
"time"
76

87
corev1 "k8s.io/api/core/v1"
9-
"k8s.io/apimachinery/pkg/labels"
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
"sigs.k8s.io/controller-runtime/pkg/client"
11-
10+
clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
1211
testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client"
1312
)
1413

@@ -32,24 +31,16 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration {
3231
return testTimeout
3332
}
3433

35-
// Check if the control plane nodes are schedulable
36-
func IsControlPlaneSchedulable() (bool, error) {
37-
controlPlaneNodesLabel := make(map[string]string)
38-
controlPlaneNodesLabel["node-role.kubernetes.io/control-plane"] = ""
39-
selector := labels.SelectorFromSet(controlPlaneNodesLabel)
40-
controlPlaneNodes := &corev1.NodeList{}
41-
if err := testclient.DataPlaneClient.List(context.TODO(), controlPlaneNodes, &client.ListOptions{LabelSelector: selector}); err != nil {
34+
// Check if the control plane nodes are schedulable, returns true if schedulable else false
35+
func IsControlPlaneSchedulable(ctx context.Context) (bool, error) {
36+
cfg, err := testclient.GetRestConfigFromClient(testclient.Client)
37+
if err != nil {
4238
return false, err
4339
}
44-
45-
if len(controlPlaneNodes.Items) == 0 {
46-
return false, fmt.Errorf("unable to fetch control plane nodes")
47-
}
48-
for _, v := range controlPlaneNodes.Items {
49-
// when control plane are schedulable, All taints are removed
50-
if len(v.Spec.Taints) != 0 {
51-
return false, nil // Not schedulable, but not an error
52-
}
40+
openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg)
41+
schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{})
42+
if err != nil {
43+
return false, err
5344
}
54-
return true, nil
45+
return schedulerInfo.Spec.MastersSchedulable, nil
5546
}

0 commit comments

Comments
 (0)