diff --git a/controllers/numaresourcesscheduler_controller.go b/controllers/numaresourcesscheduler_controller.go index 8f28675c9..b781aac26 100644 --- a/controllers/numaresourcesscheduler_controller.go +++ b/controllers/numaresourcesscheduler_controller.go @@ -55,7 +55,8 @@ import ( ) const ( - leaderElectionResourceName = "numa-scheduler-leader" + leaderElectionResourceName = "numa-scheduler-leader" + SystemNodeCriticalPriorityClass = "system-node-critical" ) const ( @@ -217,6 +218,9 @@ func (r *NUMAResourcesSchedulerReconciler) syncNUMASchedulerResources(ctx contex // TODO: if replicas doesn't make sense (autodetect disabled and user set impossible value) then we // should set a degraded state + // node-critical so the pod won't be preempted by pods having the most critical priority class + r.SchedulerManifests.Deployment.Spec.Template.Spec.PriorityClassName = SystemNodeCriticalPriorityClass + schedupdate.DeploymentImageSettings(r.SchedulerManifests.Deployment, schedSpec.SchedulerImage) cmHash := hash.ConfigMapData(r.SchedulerManifests.ConfigMap) schedupdate.DeploymentConfigMapSettings(r.SchedulerManifests.Deployment, r.SchedulerManifests.ConfigMap.Name, cmHash) diff --git a/controllers/numaresourcesscheduler_controller_test.go b/controllers/numaresourcesscheduler_controller_test.go index 326495a60..163be6a3c 100644 --- a/controllers/numaresourcesscheduler_controller_test.go +++ b/controllers/numaresourcesscheduler_controller_test.go @@ -208,6 +208,22 @@ var _ = ginkgo.Describe("Test NUMAResourcesScheduler Reconcile", func() { gomega.Expect(nrs.Status.CacheResyncPeriod.Seconds()).To(gomega.Equal(resyncPeriod.Seconds())) }) + ginkgo.It("should have the correct priority class", func() { + key := client.ObjectKeyFromObject(nrs) + _, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + key = client.ObjectKey{ + Name: "secondary-scheduler", + Namespace: testNamespace, + } + + dp := &appsv1.Deployment{} + gomega.Expect(reconciler.Client.Get(context.TODO(), key, dp)).ToNot(gomega.HaveOccurred()) + + gomega.Expect(dp.Spec.Template.Spec.PriorityClassName).To(gomega.BeEquivalentTo(SystemNodeCriticalPriorityClass)) + }) + ginkgo.It("should have a config hash annotation under deployment", func() { key := client.ObjectKeyFromObject(nrs) _, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: key})