Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ")
}
Expand Down
19 changes: 17 additions & 2 deletions test/e2e/performanceprofile/functests/utils/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"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"
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
Expand All @@ -29,3 +30,17 @@ func ComputeTestTimeout(baseTimeout time.Duration, isSno bool) time.Duration {

return testTimeout
}

// 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this config needed? can't this be done using simple client Get():

scheduler := &configv1.Scheduler{}
				Expect(testclient.DataPlaneClient.Get(ctx, client.ObjectKey{Name: "cluster"}, scheduler)).ToNot(HaveOccurred())
				return scheduler.Spec.mastersSchedulable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shajmakh
Because we are adding mastersSchedulable to true in "cluster" resource. and the API to fetch this information is available using "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" which requires rest client

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shajmakh
scheduler := &configv1.Scheduler{} ,
this is not possible, We can access scheduler after we create a new variable of configv1 struct

openshiftConfigClient := clientconfigv1.NewForConfigOrDie(<rest config>)
openshiftConfigClient.Schedulers().Get

if err != nil {
return false, err
}
openshiftConfigClient := clientconfigv1.NewForConfigOrDie(cfg)
schedulerInfo, err := openshiftConfigClient.Schedulers().Get(ctx, "cluster", metav1.GetOptions{})
if err != nil {
return false, err
}
return schedulerInfo.Spec.MastersSchedulable, nil
}