Skip to content

Commit

Permalink
e2e: check all nodes have NRT object
Browse files Browse the repository at this point in the history
The serial suite has an hidden assumption that all
nodes present in the cluster are associated with an NRT object.

Because of u/s compatability pods are allowed to be scheduled
on nodes that doesn't have NRT object, which is not
desired in the test context.

Hence, we should validate if the assumption is correct before the test begin
and not relaying on the user's good intentions.

Signed-off-by: Talor Itzhak <[email protected]>
  • Loading branch information
Tal-or committed Jan 26, 2025
1 parent b11e8b5 commit e3ab204
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/e2e/serial/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"strings"

v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"

Expand Down Expand Up @@ -163,6 +164,10 @@ func CheckNodesTopology(ctx context.Context) error {
return fmt.Errorf("Following nodes have incoherent info in KubeletConfig/NRT data:\n%#v\n", errText)
}

if err := checkNRTsArePresentForAllNodes(ctx); err != nil {
return fmt.Errorf("an NRT object must be associated with each node: %v", err)
}

singleNUMANodeNRTs := e2enrt.FilterByTopologyManagerPolicy(nrtList.Items, intnrt.SingleNUMANode)
if len(singleNUMANodeNRTs) < minNumberOfNodesWithSameTopology {
return fmt.Errorf("Not enough nodes with %q topology (found:%d). Need at least %d", intnrt.SingleNUMANode, len(singleNUMANodeNRTs), minNumberOfNodesWithSameTopology)
Expand All @@ -178,3 +183,20 @@ func errorMapToString(errs map[string]error) string {
}
return sb.String()
}

func checkNRTsArePresentForAllNodes(ctx context.Context) error {
nodeList := v1.NodeList{}
if err := e2eclient.Client.List(ctx, &nodeList); err != nil {
return err
}
nrtList := nrtv1alpha2.NodeResourceTopologyList{}
if err := e2eclient.Client.List(ctx, &nrtList); err != nil {
return err
}
for _, node := range nodeList.Items {
if _, err := e2enrt.FindFromList(nrtList.Items, node.Name); err != nil {
return err
}
}
return nil
}

0 comments on commit e3ab204

Please sign in to comment.