@@ -1543,29 +1543,6 @@ func getDriver(ethtoolstdout string) string {
15431543 return ""
15441544}
15451545
1546- func changeNodeInterfaceState (testNode string , ifcName string , enable bool ) {
1547- state := "up"
1548- if ! enable {
1549- state = "down"
1550- }
1551- podDefinition := pod .RedefineAsPrivileged (
1552- pod .RedefineWithRestartPolicy (
1553- pod .RedefineWithCommand (
1554- pod .DefineWithHostNetwork (testNode ),
1555- []string {"ip" , "link" , "set" , "dev" , ifcName , state }, []string {},
1556- ),
1557- corev1 .RestartPolicyNever ,
1558- ),
1559- )
1560- createdPod , err := clients .Pods (namespaces .Test ).Create (context .Background (), podDefinition , metav1.CreateOptions {})
1561- Expect (err ).ToNot (HaveOccurred ())
1562- Eventually (func () corev1.PodPhase {
1563- runningPod , err := clients .Pods (namespaces .Test ).Get (context .Background (), createdPod .Name , metav1.GetOptions {})
1564- Expect (err ).ToNot (HaveOccurred ())
1565- return runningPod .Status .Phase
1566- }, 3 * time .Minute , 1 * time .Second ).Should (Equal (corev1 .PodSucceeded ))
1567- }
1568-
15691546func discoverResourceForMainSriov (nodes * cluster.EnabledNodes ) (* sriovv1.InterfaceExt , string , string , bool ) {
15701547 for _ , node := range nodes .Nodes {
15711548 nodeDevices , err := nodes .FindSriovDevices (node )
@@ -1690,6 +1667,33 @@ func isDefaultRouteInterface(intfName string, routes []string) bool {
16901667 return false
16911668}
16921669
1670+ func findNoCarrierSriovDevices (testNode string , sriovDevices []* sriovv1.InterfaceExt ) ([]* sriovv1.InterfaceExt , error ) {
1671+ filteredDevices := []* sriovv1.InterfaceExt {}
1672+
1673+ for _ , device := range sriovDevices {
1674+ stdout , stderr , err := runCommandOnConfigDaemon (testNode , "/bin/bash" , "-c" , fmt .Sprintf ("ip link show %s" , device .Name ))
1675+ if err != nil {
1676+ fmt .Printf ("Can't query link state for device [%s]: %s" , device .Name , err .Error ())
1677+ continue
1678+ }
1679+
1680+ if len (stdout ) == 0 {
1681+ fmt .Printf ("Can't query link state for device [%s]: stderr:[%s]" , device .Name , stderr )
1682+ continue
1683+ }
1684+
1685+ // Check for NO-CARRIER state
1686+ if strings .Contains (stdout , "NO-CARRIER" ) {
1687+ filteredDevices = append (filteredDevices , device )
1688+ }
1689+ }
1690+ if len (filteredDevices ) == 0 {
1691+ return nil , fmt .Errorf ("no carrier sriov devices not found" )
1692+ }
1693+
1694+ return filteredDevices , nil
1695+ }
1696+
16931697// podVFIndexInHost retrieves the vf index on the host network namespace related to the given
16941698// interface that was passed to the pod, using the name in the pod's namespace.
16951699func podVFIndexInHost (hostNetPod * corev1.Pod , targetPod * corev1.Pod , interfaceName string ) (int , error ) {
0 commit comments