Skip to content

Commit

Permalink
Don't run the networkManager udev rule on virtual environments
Browse files Browse the repository at this point in the history
we can't run the udev rule on virtual environments because all the nics in that type of deployment
will be presented as VFs. this means that we are going to disable nics on the machine itself

Signed-off-by: Sebastian Sch <[email protected]>
  • Loading branch information
SchSeba committed Apr 18, 2022
1 parent 04a3f69 commit 346de67
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
11 changes: 7 additions & 4 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@ func (dn *Daemon) tryCreateUdevRuleWrapper() error {
}
}

// update udev rule and if update succeeds
err := tryCreateNMUdevRule()
if err != nil {
return err
// update udev rule only if we are on a BM environment
// for virtual environments we don't disable the vfs as they may be used by the platform/host
if dn.platform != utils.VirtualOpenStack {
err := tryCreateNMUdevRule()
if err != nil {
return err
}
}

return nil
Expand Down
20 changes: 8 additions & 12 deletions pkg/daemon/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewNodeStateStatusWriter(c snclientset.Interface, n string, f func(), devMo

// RunOnce initial the interface status for both baremetal and virtual environments
func (writer *NodeStateStatusWriter) RunOnce(destDir string, platformType utils.PlatformType) error {
glog.V(0).Infof("RunOnce(): start writer")
glog.V(0).Infof("RunOnce()")
msg := Message{}

if platformType == utils.VirtualOpenStack {
Expand All @@ -53,26 +53,22 @@ func (writer *NodeStateStatusWriter) RunOnce(destDir string, platformType utils.
return err
}

metaData, networkData, err := utils.GetOpenstackData()
if err != nil {
glog.Errorf("RunOnce(): failed to read OpenStack data: %v", err)
}

if ns == nil {
metaData, networkData, err := utils.GetOpenstackData()
if err != nil {
glog.Errorf("RunOnce(): failed to read OpenStack data: %v", err)
}

writer.openStackDevicesInfo, err = utils.CreateOpenstackDevicesInfo(metaData, networkData)
if err != nil {
return err
}
} else {
devicesInfo := make(utils.OSPDevicesInfo)
for _, iface := range ns.Status.Interfaces {
devicesInfo[iface.PciAddress] = &utils.OSPDeviceInfo{MacAddress: iface.Mac, NetworkID: iface.NetFilter}
}
writer.openStackDevicesInfo = devicesInfo
writer.openStackDevicesInfo = utils.CreateOpenstackDevicesInfoFromNodeStatus(ns)
}
}

glog.V(0).Info("RunOnce(): once")
glog.V(0).Info("RunOnce(): first poll for nic status")
if err := writer.pollNicStatus(platformType); err != nil {
glog.Errorf("RunOnce(): first poll failed: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func getNetdevMTU(pciAddr string) int {
}

func getNetDevMac(ifaceName string) string {
glog.Infof("getNetDevMac(): get Mac for device %s", ifaceName)
glog.V(2).Infof("getNetDevMac(): get Mac for device %s", ifaceName)
macFilePath := filepath.Join(sysClassNet, ifaceName, "address")
data, err := ioutil.ReadFile(macFilePath)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/utils/utils_virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ func DiscoverSriovDevicesVirtual(devicesInfo OSPDevicesInfo) ([]sriovnetworkv1.I
return pfList, nil
}

func CreateOpenstackDevicesInfoFromNodeStatus(networkState *sriovnetworkv1.SriovNetworkNodeState) OSPDevicesInfo {
devicesInfo := make(OSPDevicesInfo)
for _, iface := range networkState.Status.Interfaces {
devicesInfo[iface.PciAddress] = &OSPDeviceInfo{MacAddress: iface.Mac, NetworkID: iface.NetFilter}
}

return devicesInfo
}

// tryToGetVirtualInterfaceName get the interface name of a virtio interface
func tryToGetVirtualInterfaceName(pciAddr string) string {
glog.Infof("tryToGetVirtualInterfaceName() get interface name for device %s", pciAddr)
Expand Down

0 comments on commit 346de67

Please sign in to comment.