Skip to content

Commit

Permalink
Fix bugs of bdf type
Browse files Browse the repository at this point in the history
  • Loading branch information
mowangdk committed Oct 21, 2024
1 parent 5ba68f8 commit 5e73aa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions pkg/disk/device_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strings"
"regexp"

utilsio "github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/utils/io"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -266,13 +267,18 @@ func (m *DeviceManager) GetDeviceNumberFromBlockDevice(blockDevice, busPrefix st
}
for {
klog.Infof("NewDeviceDriver: get symlink dir: %s", dirEntry)
if dirEntry == ".." || dirEntry == "." {
if dirEntry == ".." || dirEntry == "." || dirEntry == "/" {
return "", fmt.Errorf("NewDeviceDriver: not found device number, blockDevice: %s", blockDevice)
}
parentDir := filepath.Base(filepath.Dir(dirEntry))
if strings.HasPrefix(parentDir, busPrefix) {
matched, err := regexp.MatchString(busPrefix, parentDir)
klog.Infof("NewDeviceDriver: busPrefix: %s, parentDir: %s", busPrefix, parentDir)
if matched && err == nil {
return parentDir, nil
} else {
if err != nil {
klog.Infof("NewDeviceDriver: disk not match with device partten err: %s", err.Error())
}
dirEntry = filepath.Dir(dirEntry)
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/disk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ const (
// RundVolumeType specific which volume type is passed to rund
rundBlockVolumeType = "block"
// BDFTypeDevice defines the prefix of bdf number
BDFTypeDevice = "0000:"
BDFTypeDevice = "\b[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}"
// BDFTypeBus defines bdf bus type
BDFTypeBus = "pci"
// DFBusTypeDevice defines the prefix of dfnumber
DFBusTypeDevice = "dfvirtio"
DFBusTypeDevice = "\bdfvirtio.*"
// DFBusTypeBus defines df bus type
DFBusTypeBus = "dragonfly"
// DFBusTypeVFIO defines df bus vfio driver type
Expand Down Expand Up @@ -1342,6 +1342,7 @@ func (ns *nodeServer) mountRunDVolumes(volumeId, pvName, sourcePath, targetPath,
return true, status.Error(codes.InvalidArgument, "NodePublishVolume: unmountStageTarget "+sourcePath+" with error: "+err.Error())
}

klog.InfoS("mountRunDVolumes: ", "deviceName", deviceName)
driver, err := NewDeviceDriver(volumeId, deviceName, deviceNumber, ns.kataBMIOType, map[string]string{})
if err != nil {
klog.Errorf("NodePublishVolume(rund3.0): can't get bdf number of volume: %s: err: %v", volumeId, err)
Expand Down

0 comments on commit 5e73aa0

Please sign in to comment.