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:
vpickard
2020-03-03 14:52:15 -05:00
parent 06b798781a
commit 61565b3f6c

View File

@@ -20,6 +20,7 @@ import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
testutils "k8s.io/kubernetes/test/utils"
"os/exec" "os/exec"
"regexp" "regexp"
"strconv" "strconv"
@@ -50,8 +51,9 @@ import (
const ( const (
numalignCmd = `export CPULIST_ALLOWED=$( awk -F":\t*" '/Cpus_allowed_list/ { print $2 }' /proc/self/status); env; sleep 1d` numalignCmd = `export CPULIST_ALLOWED=$( awk -F":\t*" '/Cpus_allowed_list/ { print $2 }' /proc/self/status); env; sleep 1d`
minNumaNodes = 2 minNumaNodes = 2
minCoreCount = 4 minCoreCount = 4
minSriovResource = 7 // This is the min number of SRIOV VFs needed on the system under test.
) )
// Helper for makeTopologyManagerPod(). // Helper for makeTopologyManagerPod().
@@ -284,8 +286,9 @@ func readServiceAccountV1OrDie(objBytes []byte) *v1.ServiceAccount {
} }
func findSRIOVResource(node *v1.Node) (string, int64) { func findSRIOVResource(node *v1.Node) (string, int64) {
framework.Logf("Node status allocatable: %v", node.Status.Allocatable)
re := regexp.MustCompile(`^intel.com/.*sriov.*`) re := regexp.MustCompile(`^intel.com/.*sriov.*`)
for key, val := range node.Status.Capacity { for key, val := range node.Status.Allocatable {
resource := string(key) resource := string(key)
if re.MatchString(resource) { if re.MatchString(resource) {
v := val.Value() 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{}) dpPod, err := f.ClientSet.CoreV1().Pods(metav1.NamespaceSystem).Create(context.TODO(), dp, metav1.CreateOptions{})
framework.ExpectNoError(err) 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 := "" sriovResourceName := ""
var sriovResourceAmount int64 var sriovResourceAmount int64
ginkgo.By("Waiting for devices to become available on the local node") ginkgo.By("Waiting for devices to become available on the local node")
gomega.Eventually(func() bool { gomega.Eventually(func() bool {
node := getLocalNode(f) node := getLocalNode(f)
framework.Logf("Node status: %v", node.Status.Capacity)
sriovResourceName, sriovResourceAmount = findSRIOVResource(node) sriovResourceName, sriovResourceAmount = findSRIOVResource(node)
return sriovResourceAmount > 0 return sriovResourceAmount > minSriovResource
}, 2*time.Minute, framework.Poll).Should(gomega.BeTrue()) }, 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{ return &sriovData{
configMap: configMap, configMap: configMap,