mirror of https://github.com/k3s-io/k3s
Adding rescan scsi controller for cinder
For lsilogic scsi controller, attached cinder volume does not appear under /dev/ automatically unless do a rescan. This approach was used in vSphere volume provider before PR #27496 dropped support for lsilogic scsi controller.pull/6/head
parent
3b43ce8e5c
commit
89c0aa735a
|
@ -19,6 +19,7 @@ package cinder
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -174,6 +175,9 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
|
|||
}
|
||||
|
||||
func probeAttachedVolume() error {
|
||||
// rescan scsi bus
|
||||
scsiHostRescan()
|
||||
|
||||
executor := exec.New()
|
||||
args := []string{"trigger"}
|
||||
cmd := executor.Command("/usr/bin/udevadm", args...)
|
||||
|
@ -185,3 +189,14 @@ func probeAttachedVolume() error {
|
|||
glog.V(4).Infof("Successfully probed all attachments")
|
||||
return nil
|
||||
}
|
||||
|
||||
func scsiHostRescan() {
|
||||
scsi_path := "/sys/class/scsi_host/"
|
||||
if dirs, err := ioutil.ReadDir(scsi_path); err == nil {
|
||||
for _, f := range dirs {
|
||||
name := scsi_path + f.Name() + "/scan"
|
||||
data := []byte("- - -")
|
||||
ioutil.WriteFile(name, data, 0666)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue