Merge pull request #7847 from swagiaal/fix-gce-pd-on-atomic-host
Support default udev GCE PD device path
This commit is contained in:
commit
aa744f92da
@ -42,19 +42,34 @@ func (util *GCEDiskUtil) AttachAndMountDisk(pd *gcePersistentDisk, globalPDPath
|
|||||||
if err := gce.(*gce_cloud.GCECloud).AttachDisk(pd.pdName, pd.readOnly); err != nil {
|
if err := gce.(*gce_cloud.GCECloud).AttachDisk(pd.pdName, pd.readOnly); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
devicePath := path.Join("/dev/disk/by-id/", "google-"+pd.pdName)
|
|
||||||
|
devicePaths := []string{
|
||||||
|
path.Join("/dev/disk/by-id/", "google-"+pd.pdName),
|
||||||
|
path.Join("/dev/disk/by-id/", "scsi-0Google_PersistentDisk_"+pd.pdName),
|
||||||
|
}
|
||||||
|
|
||||||
if pd.partition != "" {
|
if pd.partition != "" {
|
||||||
devicePath = devicePath + "-part" + pd.partition
|
for i, path := range devicePaths {
|
||||||
|
devicePaths[i] = path + "-part" + pd.partition
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//TODO(jonesdl) There should probably be better method than busy-waiting here.
|
//TODO(jonesdl) There should probably be better method than busy-waiting here.
|
||||||
numTries := 0
|
numTries := 0
|
||||||
|
devicePath := ""
|
||||||
|
// Wait for the disk device to be created
|
||||||
for {
|
for {
|
||||||
_, err := os.Stat(devicePath)
|
for _, path := range devicePaths {
|
||||||
if err == nil {
|
_, err := os.Stat(path)
|
||||||
break
|
if err == nil {
|
||||||
|
devicePath = path
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if devicePath != "" {
|
||||||
return err
|
break
|
||||||
}
|
}
|
||||||
numTries++
|
numTries++
|
||||||
if numTries == 10 {
|
if numTries == 10 {
|
||||||
|
Loading…
Reference in New Issue
Block a user