Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.6] Pao run master nodes #374

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -118,6 +118,13 @@ spec:
labels:
name: performance-operator
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/master
operator: Exists
containers:
- command:
- performance-operator
Expand All @@ -137,6 +144,9 @@ spec:
name: performance-operator
resources: {}
serviceAccountName: performance-operator
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
permissions:
- rules:
- apiGroups:
Expand Down
10 changes: 10 additions & 0 deletions deploy/operator.yaml
Expand Up @@ -13,6 +13,16 @@ spec:
name: performance-operator
spec:
serviceAccountName: performance-operator
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/master
operator: Exists
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: performance-operator
# Replace this with the built image name
Expand Down
24 changes: 24 additions & 0 deletions functests/1_performance/performance.go
Expand Up @@ -10,6 +10,7 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"

corev1 "k8s.io/api/core/v1"
"k8s.io/api/node/v1beta1"
Expand Down Expand Up @@ -61,6 +62,29 @@ var _ = Describe("[rfe_id:27368][performance]", func() {
Expect(err).ToNot(HaveOccurred())
})

// self-tests; these are only vaguely related to performance becase these are enablement conditions, not actual settings.
// For example, running on control plane means we leave more resources for the workload.
Context("Performance Operator", func() {
It("Should run on the control plane nodes", func() {
pod, err := pods.GetPerformanceOperatorPod()
Expect(err).ToNot(HaveOccurred(), "Failed to find the Performance Addon Operator pod")

Expect(strings.HasPrefix(pod.Name, "performance-operator")).To(BeTrue(),
"Performance Addon Operator pod name should start with performance-operator prefix")

masterNodes, err := nodes.GetByRole(testutils.RoleMaster)
Expect(err).ToNot(HaveOccurred(), "Failed to query the master nodes")
for _, node := range masterNodes {
if node.Name == pod.Spec.NodeName {
return
}
}

// Fail
Expect(true).To(Reject(), "Performance Addon Operator is not running in a master node")
})
})

Context("Tuned CRs generated from profile", func() {
It("[test_id:31748] Should have the expected name for tuned from the profile owner object", func() {
tunedExpectedName := components.GetComponentName(testutils.PerformanceProfileName, components.ProfileNamePerformance)
Expand Down
2 changes: 2 additions & 0 deletions functests/utils/consts.go
Expand Up @@ -67,6 +67,8 @@ func init() {
const (
// RoleWorker contains the worker role
RoleWorker = "worker"
// RoleMaster contains the master role
RoleMaster = "master"
)

const (
Expand Down
22 changes: 22 additions & 0 deletions functests/utils/pods/pods.go
Expand Up @@ -11,9 +11,11 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"

testutils "github.com/openshift-kni/performance-addon-operators/functests/utils"
testclient "github.com/openshift-kni/performance-addon-operators/functests/utils/client"
Expand Down Expand Up @@ -143,3 +145,23 @@ func GetContainerIDByName(pod *corev1.Pod, containerName string) (string, error)
}
return "", fmt.Errorf("failed to find the container ID for the container %q under the pod %q", containerName, pod.Name)
}

// GetPerformanceOperatorPod returns the pod running the Performance Profile Operator
func GetPerformanceOperatorPod() (*corev1.Pod, error) {
selector, err := labels.Parse(fmt.Sprintf("%s=%s", "name", "performance-operator"))
if err != nil {
return nil, err
}

pods := &corev1.PodList{}

opts := &client.ListOptions{LabelSelector: selector, Namespace: testutils.PerformanceOperatorNamespace}
if err := testclient.Client.List(context.TODO(), pods, opts); err != nil {
return nil, err
}
if len(pods.Items) != 1 {
return nil, fmt.Errorf("incorrect performance operator pods count: %d", len(pods.Items))
}

return &pods.Items[0], nil
}