From 27dec8db552f8f341f7120611f35b9e040d1175b Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Tue, 23 Sep 2025 11:27:51 +0530 Subject: [PATCH 1/5] Add function to check control plane is schedulable Signed-off-by: Niranjan M.R --- .../functests/utils/cluster/cluster.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go index 8f4413a97f..4a568e6197 100644 --- a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go +++ b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go @@ -2,9 +2,11 @@ package cluster import ( "context" + "fmt" "time" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client" @@ -29,3 +31,25 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration { return testTimeout } + +// Check if the control plane nodes are schedulable +func IsControlPlaneSchedulable() (bool, error) { + controlPlaneNodesLabel := make(map[string]string) + controlPlaneNodesLabel["node-role.kubernetes.io/control-plane"] = "" + selector := labels.SelectorFromSet(controlPlaneNodesLabel) + controlPlaneNodes := &corev1.NodeList{} + if err := testclient.DataPlaneClient.List(context.TODO(), controlPlaneNodes, &client.ListOptions{LabelSelector: selector}); err != nil { + return false, err + } + + if len(controlPlaneNodes.Items) == 0 { + return false, fmt.Errorf("unable to fetch control plane nodes") + } + for _, v := range controlPlaneNodes.Items { + // when control plane are schedulable, All taints are removed + if len(v.Spec.Taints) != 0 { + return false, nil // Not schedulable, but not an error + } + } + return true, nil +} From 3bb4fef5709283fa55392cd724046501877a72bb Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Tue, 23 Sep 2025 13:43:53 +0530 Subject: [PATCH 2/5] Skip Node selector tests when control planes are schedulable Skip Node selector tests when control plane nodes are schedulable since this tests primarily adds and deletes mcp on worker nodes and modifies the performance profile appropriately. This test is not applicable when control plane nodes are schedulable and we are relying on performance profile applied to control plane nodes Signed-off-by: Niranjan M.R --- .../functests/2_performance_update/updating_profile.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go b/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go index 9aa8c754d8..0a8ed6c21e 100644 --- a/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go +++ b/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go @@ -31,6 +31,7 @@ import ( testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cgroup/runtime" testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client" + "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cluster" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/hypershift" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/label" @@ -404,6 +405,12 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance if len(nonPerformancesWorkers) > 1 { newCnfNode = &nonPerformancesWorkers[0] } + ok, err := cluster.IsControlPlaneSchedulable() + Expect(err).ToNot(HaveOccurred(), "Unable to fetch schedulable information of control plane nodes: %v", err) + if ok { + Skip("Skipping the test - Control plane nodes are schedulable") + } + if newCnfNode == nil { Skip("Skipping the test - cluster does not have another available worker node ") } From 8d30a26f7f8c72e7ff08d245fa4ebd1986650871 Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Wed, 24 Sep 2025 18:11:11 +0530 Subject: [PATCH 3/5] Use openshift api to fetch control plane nodes schedulable info Signed-off-by: Niranjan M.R --- .../functests/utils/cluster/cluster.go | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go index 4a568e6197..4b50328a69 100644 --- a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go +++ b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go @@ -2,14 +2,13 @@ package cluster import ( "context" - "fmt" "time" + clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" + testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/labels" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - - testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client" ) // IsSingleNode validates if the environment is single node cluster @@ -32,24 +31,16 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration { return testTimeout } -// Check if the control plane nodes are schedulable -func IsControlPlaneSchedulable() (bool, error) { - controlPlaneNodesLabel := make(map[string]string) - controlPlaneNodesLabel["node-role.kubernetes.io/control-plane"] = "" - selector := labels.SelectorFromSet(controlPlaneNodesLabel) - controlPlaneNodes := &corev1.NodeList{} - if err := testclient.DataPlaneClient.List(context.TODO(), controlPlaneNodes, &client.ListOptions{LabelSelector: selector}); err != nil { +// Check if the control plane nodes are schedulable, returns true if schedulable else false +func IsControlPlaneSchedulable(ctx context.Context) (bool, error) { + cfg, err := testclient.GetRestConfigFromClient(testclient.Client) + if err != nil { return false, err } - - if len(controlPlaneNodes.Items) == 0 { - return false, fmt.Errorf("unable to fetch control plane nodes") - } - for _, v := range controlPlaneNodes.Items { - // when control plane are schedulable, All taints are removed - if len(v.Spec.Taints) != 0 { - return false, nil // Not schedulable, but not an error - } + openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg) + schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{}) + if err != nil { + return false, err } - return true, nil + return schedulerInfo.Spec.MastersSchedulable, nil } From 516d0e8aea8b9cdbe0a9efb285d9e588cbcc2570 Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Wed, 24 Sep 2025 19:53:40 +0530 Subject: [PATCH 4/5] Get rest config required to access api server Signed-off-by: Niranjan M.R --- .../performanceprofile/functests/utils/cluster/cluster.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go index 4b50328a69..44bc1e2dba 100644 --- a/test/e2e/performanceprofile/functests/utils/cluster/cluster.go +++ b/test/e2e/performanceprofile/functests/utils/cluster/cluster.go @@ -9,6 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/config" ) // IsSingleNode validates if the environment is single node cluster @@ -33,10 +34,12 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration { // Check if the control plane nodes are schedulable, returns true if schedulable else false func IsControlPlaneSchedulable(ctx context.Context) (bool, error) { - cfg, err := testclient.GetRestConfigFromClient(testclient.Client) + // Get the rest.Config using the helper function + cfg, err := config.GetConfig() if err != nil { return false, err } + openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg) schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{}) if err != nil { From edfbe281405eaef0e6f5f64ecfdca1850a505ffb Mon Sep 17 00:00:00 2001 From: "Niranjan M.R" Date: Wed, 24 Sep 2025 20:12:34 +0530 Subject: [PATCH 5/5] Pass context.TODO() to IsControlPlaneSchedulable function Signed-off-by: Niranjan M.R --- .../functests/2_performance_update/updating_profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go b/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go index 0a8ed6c21e..856788b764 100644 --- a/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go +++ b/test/e2e/performanceprofile/functests/2_performance_update/updating_profile.go @@ -405,7 +405,7 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance if len(nonPerformancesWorkers) > 1 { newCnfNode = &nonPerformancesWorkers[0] } - ok, err := cluster.IsControlPlaneSchedulable() + ok, err := cluster.IsControlPlaneSchedulable(context.TODO()) Expect(err).ToNot(HaveOccurred(), "Unable to fetch schedulable information of control plane nodes: %v", err) if ok { Skip("Skipping the test - Control plane nodes are schedulable")