mirror of https://github.com/k3s-io/k3s
Merge pull request #37275 from xiangfeiz/cinder-rescan-scsi
Automatic merge from submit-queue 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
commit
68f123dfa0
|
@ -19,6 +19,7 @@ package cinder
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -174,6 +175,9 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
|
||||||
}
|
}
|
||||||
|
|
||||||
func probeAttachedVolume() error {
|
func probeAttachedVolume() error {
|
||||||
|
// rescan scsi bus
|
||||||
|
scsiHostRescan()
|
||||||
|
|
||||||
executor := exec.New()
|
executor := exec.New()
|
||||||
args := []string{"trigger"}
|
args := []string{"trigger"}
|
||||||
cmd := executor.Command("/usr/bin/udevadm", args...)
|
cmd := executor.Command("/usr/bin/udevadm", args...)
|
||||||
|
@ -185,3 +189,14 @@ func probeAttachedVolume() error {
|
||||||
glog.V(4).Infof("Successfully probed all attachments")
|
glog.V(4).Infof("Successfully probed all attachments")
|
||||||
return nil
|
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