Skip to content

Commit

Permalink
Derive link type from PF if the interface name is not available
Browse files Browse the repository at this point in the history
In case a workload is already consuming a VF and
sriov-device-plugin is restarted,
when this selector is specified, the device plugin will fail
to get the VF link type since getting this information
requires the VF netdev. The netdev does not exist in the host namespace
as its assigned to pod. this causes sriov-network-device-plugin to fail
adding this VF to resource pool,
causing it to report the wrong number of resources.

To fix this, derive the link type of the device from its PF,
if the netdev itself is not available.

Signed-off-by: amaslennikov <amaslennikov@nvidia.com>
  • Loading branch information
almaslennikov committed Apr 13, 2023
1 parent 2897303 commit c92f7ac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/devices/gen_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewGenNetDevice(deviceID string, dt types.DeviceType, isRdma bool) (*GenNet
var funcID int
var err error

//nolint: exhaustive
// nolint: exhaustive
switch dt {
case types.NetDeviceType:
if pfName, err = utils.GetPfName(deviceID); err != nil {
Expand Down Expand Up @@ -82,8 +82,13 @@ func NewGenNetDevice(deviceID string, dt types.DeviceType, isRdma bool) (*GenNet
}

linkType := ""
if len(ifName) > 0 {
la, err := utils.GetNetlinkProvider().GetLinkAttrs(ifName)
linkTypeProviderDevice := ifName
// If interface name is not available, derive link type from PF
if linkTypeProviderDevice == "" {
linkTypeProviderDevice = pfName
}
if linkTypeProviderDevice != "" {
la, err := utils.GetNetlinkProvider().GetLinkAttrs(linkTypeProviderDevice)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c92f7ac

Please sign in to comment.