Commit e2e2b612 authored by Stephen Greene's avatar Stephen Greene
Browse files

canary: Add priority class to canary daemonset

OpenShift components are required to specify a
PriorityClassName for daemonsets/deployments.

This commit ensures that the Canary daemonset has the
`system-cluster-critical` priority class set.

assets/canary/daemonset.yaml:
Set the `priorityClassName` field to be `system-cluster-critical`.

pkg/operator/controller/canary/daemonset.go:
Update the Canary daemonset when `priorityClassName` changes.

pkg/operator/controller/canary/daemonset_test.go:
Add a test to ensure that `priorityClassName` is set correctly by
`desiredCanaryDaemonSet`.
Add a test to verify that the Canary daemonset is updated
when `priorityClassName` is mutated.

This commit is in support of Bug 1954892.
parent 455fbd0e
......@@ -10,6 +10,7 @@ spec:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
priorityClassName: system-cluster-critical
containers:
- name: serve-healthcheck-canary
# Image and command are set at runtime
......
......@@ -131,6 +131,11 @@ func canaryDaemonSetChanged(current, expected *appsv1.DaemonSet) (bool, *appsv1.
changed = true
}
if current.Spec.Template.Spec.PriorityClassName != expected.Spec.Template.Spec.PriorityClassName {
updated.Spec.Template.Spec.PriorityClassName = expected.Spec.Template.Spec.PriorityClassName
changed = true
}
if !changed {
return false, nil
}
......
......@@ -65,7 +65,12 @@ func TestDesiredCanaryDaemonSet(t *testing.T) {
}
if !cmp.Equal(nodeSelector, expectedNodeSelector) {
t.Errorf("expected daemonset node selector to be %q, but got %q", expectedNodeSelector, nodeSelector)
}
priorityClass := daemonset.Spec.Template.Spec.PriorityClassName
expectedPriorityClass := "system-cluster-critical"
if !cmp.Equal(priorityClass, expectedPriorityClass) {
t.Errorf("expected daemonset priority class to be %q, but got %q", expectedPriorityClass, priorityClass)
}
tolerations := daemonset.Spec.Template.Spec.Tolerations
......@@ -144,6 +149,13 @@ func TestCanaryDaemonsetChanged(t *testing.T) {
},
expect: true,
},
{
description: "if canary daemonset priority class changed",
mutate: func(ds *appsv1.DaemonSet) {
ds.Spec.Template.Spec.PriorityClassName = "my-priority-class"
},
expect: true,
},
}
for _, tc := range testCases {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment