mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
e2e-topology-manager: Wait for SR-IOV device plugin
Make sure the SR-IOV device plugin is ready, and that there are enough SR-IOV devices allocatable before spinning up test pods. Signed-off-by: vpickard <vpickard@redhat.com>
This commit is contained in:
parent
06b798781a
commit
61565b3f6c
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -50,8 +51,9 @@ import (
|
||||
const (
|
||||
numalignCmd = `export CPULIST_ALLOWED=$( awk -F":\t*" '/Cpus_allowed_list/ { print $2 }' /proc/self/status); env; sleep 1d`
|
||||
|
||||
minNumaNodes = 2
|
||||
minCoreCount = 4
|
||||
minNumaNodes = 2
|
||||
minCoreCount = 4
|
||||
minSriovResource = 7 // This is the min number of SRIOV VFs needed on the system under test.
|
||||
)
|
||||
|
||||
// Helper for makeTopologyManagerPod().
|
||||
@ -284,8 +286,9 @@ func readServiceAccountV1OrDie(objBytes []byte) *v1.ServiceAccount {
|
||||
}
|
||||
|
||||
func findSRIOVResource(node *v1.Node) (string, int64) {
|
||||
framework.Logf("Node status allocatable: %v", node.Status.Allocatable)
|
||||
re := regexp.MustCompile(`^intel.com/.*sriov.*`)
|
||||
for key, val := range node.Status.Capacity {
|
||||
for key, val := range node.Status.Allocatable {
|
||||
resource := string(key)
|
||||
if re.MatchString(resource) {
|
||||
v := val.Value()
|
||||
@ -666,16 +669,20 @@ func setupSRIOVConfigOrFail(f *framework.Framework, configMap *v1.ConfigMap) *sr
|
||||
dpPod, err := f.ClientSet.CoreV1().Pods(metav1.NamespaceSystem).Create(context.TODO(), dp, metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
if err = e2epod.WaitForPodCondition(f.ClientSet, metav1.NamespaceSystem, dp.Name, "Ready", 120*time.Second, testutils.PodRunningReady); err != nil {
|
||||
framework.Logf("SRIOV Pod %v took too long to enter running/ready: %v", dp.Name, err)
|
||||
}
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
sriovResourceName := ""
|
||||
var sriovResourceAmount int64
|
||||
ginkgo.By("Waiting for devices to become available on the local node")
|
||||
gomega.Eventually(func() bool {
|
||||
node := getLocalNode(f)
|
||||
framework.Logf("Node status: %v", node.Status.Capacity)
|
||||
sriovResourceName, sriovResourceAmount = findSRIOVResource(node)
|
||||
return sriovResourceAmount > 0
|
||||
return sriovResourceAmount > minSriovResource
|
||||
}, 2*time.Minute, framework.Poll).Should(gomega.BeTrue())
|
||||
framework.Logf("Successfully created device plugin pod, detected %d SRIOV device %q", sriovResourceAmount, sriovResourceName)
|
||||
framework.Logf("Successfully created device plugin pod, detected %d SRIOV allocatable devices %q", sriovResourceAmount, sriovResourceName)
|
||||
|
||||
return &sriovData{
|
||||
configMap: configMap,
|
||||
|
Loading…
Reference in New Issue
Block a user