@@ -37,11 +37,13 @@ import (
3737 machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
3838
3939 "github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux"
40+ "github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
4041 "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/rte"
4142 nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
4243
4344 nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
4445 inthelper "github.com/openshift-kni/numaresources-operator/internal/api/annotations/helper"
46+ nrolabels "github.com/openshift-kni/numaresources-operator/internal/api/labels"
4547 nropmcp "github.com/openshift-kni/numaresources-operator/internal/machineconfigpools"
4648 "github.com/openshift-kni/numaresources-operator/internal/podlogs"
4749 nrowait "github.com/openshift-kni/numaresources-operator/internal/wait"
@@ -151,6 +153,8 @@ var _ = Describe("[Install] continuousIntegration", Serial, func() {
151153 rteContainer , err := findContainerByName (* ds , containerNameRTE )
152154 Expect (err ).ToNot (HaveOccurred ())
153155 Expect (rteContainer .SecurityContext .SELinuxOptions .Type ).To (Equal (selinux .RTEContextType ), "container %s is running with wrong selinux context" , rteContainer .Name )
156+
157+ expectNROPrimaryPoolLabelsPresent (ds )
154158 })
155159 })
156160})
@@ -265,10 +269,14 @@ var _ = Describe("[Install] durability", Serial, func() {
265269 return err
266270 }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (Succeed ())
267271
272+ expectNROPrimaryPoolLabelsPresent (ds )
273+
268274 deleteNROPSync (e2eclient .Client , nroObj )
269275
270276 deploy .WaitForMCPUpdatedAfterNRODeleted (nroObj )
271277
278+ expectNROPrimaryPoolLabelsAbsent ()
279+
272280 By ("checking there are no leftovers" )
273281 // by taking the ns from the ds we're avoiding the need to figure out in advanced
274282 // at which ns we should look for the resources
@@ -326,6 +334,7 @@ var _ = Describe("[Install] durability", Serial, func() {
326334 return ds .Spec .Template .Spec .Containers [0 ].Image == e2eimages .RTETestImageCI
327335 }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (BeTrue ())
328336 })
337+
329338 It ("should have the desired topology manager configuration under the NRT object" , func () {
330339 rteConfigMap := & corev1.ConfigMap {}
331340 Eventually (func () bool {
@@ -415,6 +424,45 @@ func getDaemonSetByOwnerReference(uid types.UID) (*appsv1.DaemonSet, error) {
415424 return nil , fmt .Errorf ("failed to get daemonset with owner reference uid: %s" , uid )
416425}
417426
427+ func expectNROPrimaryPoolLabelsPresent (ds * appsv1.DaemonSet ) {
428+ GinkgoHelper ()
429+ if configuration .Plat != platform .OpenShift {
430+ return
431+ }
432+
433+ By ("checking that managed nodes have the NRO primary-pool label" )
434+ sel , err := labels .Parse (nrolabels .NodePrimaryPool )
435+ Expect (err ).ToNot (HaveOccurred ())
436+ nodeList := & corev1.NodeList {}
437+ err = e2eclient .Client .List (context .TODO (), nodeList , & client.ListOptions {LabelSelector : sel })
438+ Expect (err ).ToNot (HaveOccurred ())
439+ Expect (nodeList .Items ).ToNot (BeEmpty (), "expected at least one node with the NRO primary-pool label" )
440+ for _ , node := range nodeList .Items {
441+ val := node .Labels [nrolabels .NodePrimaryPool ]
442+ Expect (val ).ToNot (BeEmpty (), "node %s has the NRO label key but empty value" , node .Name )
443+ klog .InfoS ("node has NRO primary-pool label" , "node" , node .Name , "pool" , val )
444+ }
445+
446+ By ("checking that the DaemonSet NodeSelector uses the NRO primary-pool label" )
447+ _ , hasKey := ds .Spec .Template .Spec .NodeSelector [nrolabels .NodePrimaryPool ]
448+ Expect (hasKey ).To (BeTrue (), "DaemonSet NodeSelector should contain %s" , nrolabels .NodePrimaryPool )
449+ }
450+
451+ func expectNROPrimaryPoolLabelsAbsent () {
452+ GinkgoHelper ()
453+ if configuration .Plat != platform .OpenShift {
454+ return
455+ }
456+
457+ By ("checking that the NRO primary-pool labels were removed from all nodes" )
458+ sel , err := labels .Parse (nrolabels .NodePrimaryPool )
459+ Expect (err ).ToNot (HaveOccurred ())
460+ nodeList := & corev1.NodeList {}
461+ err = e2eclient .Client .List (context .TODO (), nodeList , & client.ListOptions {LabelSelector : sel })
462+ Expect (err ).ToNot (HaveOccurred ())
463+ Expect (nodeList .Items ).To (BeEmpty (), "expected no nodes with the NRO primary-pool label after deletion, but found %d" , len (nodeList .Items ))
464+ }
465+
418466func logRTEPodsLogs (cli client.Client , k8sCli * kubernetes.Clientset , ctx context.Context , nroObj * nropv1.NUMAResourcesOperator , reason string ) {
419467 dss , err := objects .GetDaemonSetsByNamespacedName (cli , ctx , nroObj .Status .DaemonSets ... )
420468 if err != nil {
0 commit comments