-
Notifications
You must be signed in to change notification settings - Fork 60
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
Force PAO installation on master nodes #351
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,12 @@ import ( | |
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gstruct" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. used by Reject() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. And BTW this is exacty why I dislike the dot imports. |
||
|
||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
|
@@ -27,6 +29,8 @@ import ( | |
testclient "github.com/openshift-kni/performance-addon-operators/functests/utils/client" | ||
"github.com/openshift-kni/performance-addon-operators/functests/utils/discovery" | ||
"github.com/openshift-kni/performance-addon-operators/functests/utils/mcps" | ||
"github.com/openshift-kni/performance-addon-operators/functests/utils/nodes" | ||
"github.com/openshift-kni/performance-addon-operators/functests/utils/pods" | ||
"github.com/openshift-kni/performance-addon-operators/functests/utils/profiles" | ||
"github.com/openshift-kni/performance-addon-operators/pkg/apis" | ||
performancev1 "github.com/openshift-kni/performance-addon-operators/pkg/apis/performance/v1" | ||
|
@@ -37,6 +41,25 @@ import ( | |
|
||
var _ = Describe("[performance][config] Performance configuration", func() { | ||
|
||
It("Should run performance profile pod on a master node", 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 { | ||
marcel-apf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if node.Name == pod.Spec.NodeName { | ||
return | ||
} | ||
} | ||
|
||
// Fail | ||
Expect(true).To(Reject(), "Performance Addon Operator is not running in a master node") | ||
}) | ||
|
||
It("Should successfully deploy the performance profile", func() { | ||
|
||
performanceProfile := testProfile() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should just use len(pods.Items) < 1 (just in case we eventually add HA and leader election). Or maybe it would be premature to change the test now, so just asking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point, I prefer to keep the test as-is and see it break first when/if we add the HA/leader election. |
||
return nil, fmt.Errorf("incorrect performance operator pods count: %d", len(pods.Items)) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any way to check that pod is indeeded running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the same namespace as PAO "openshift-performance-addon" ? I think is a relatively safe bet... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still a bet, meaning is still anecdotal evidence, and we need quite some of it to gain confidence. Checking the image name seems stronger (does it contain 'performance-operator'). Feel free to add more checks, or to lookup better ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are also checking we have only one pod in the namespace. The check is the first step in the func tests, I suppose the next steps will fail if for some reason the PAO is not in the namespace, but another pod with same label. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added check the performance operator pod name (not label) starts with "performance-operator" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should increase the confidence in the bet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still not completely happy with this solution, but good enough for now. |
||
return &pods.Items[0], nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems OCP control plane is using
but the end result is the same and affinity rules are more powerful than nodeSelector, so it seems is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferred affinity since is is reflected in the official docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is affinity reflected in the openshift official docs or the kubernetes official docs? or both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both