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
Kubernetes Submit Queue 2017-01-24 06:24:59 -08:00 committed by GitHub
commit 68f123dfa0
1 changed files with 15 additions and 0 deletions

View File

@ -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)
}
}
}