Merge pull request #9791 from wanyaoqi/automated-cherry-pick-of-#9790-upstream-release-3.7

Automated cherry pick of #9790: fix(host-deployer): add retry on check is vgactived
This commit is contained in:
Zexi Li
2021-01-07 21:18:07 +08:00
committed by GitHub
3 changed files with 14 additions and 6 deletions
+1
View File
@@ -88,6 +88,7 @@ func (d *SKVMGuestDisk) MountKvmRootfs() fsdriver.IRootFsDriver {
func (d *SKVMGuestDisk) mountKvmRootfs(readonly bool) fsdriver.IRootFsDriver {
partitions := d.deployer.GetPartitions()
for i := 0; i < len(partitions); i++ {
log.Infof("detect partition %s", partitions[i].GetPartDev())
mountFunc := partitions[i].Mount
if readonly {
mountFunc = partitions[i].MountPartReadOnly
+1
View File
@@ -164,6 +164,7 @@ func (d *NBDDriver) setupLVMS() (bool, error) {
for _, part := range d.partitions {
vgname := d.findLVMPartitions(part.GetPartDev())
if len(vgname) > 0 {
log.Infof("find vg %s from %s", vgname, part.GetPartDev())
lvm := NewKVMGuestLVMPartition(part.GetPartDev(), vgname)
d.lvms = append(d.lvms, lvm)
if lvm.SetupDevice() {
+12 -6
View File
@@ -20,6 +20,7 @@ import (
"regexp"
"strings"
"sync"
"time"
"yunion.io/x/log"
"yunion.io/x/pkg/util/stringutils"
@@ -132,13 +133,11 @@ func (p *SKVMGuestLVMPartition) FindPartitions() []*kvmpart.SKVMGuestDiskPartiti
if !p.isVgActive() {
return nil
}
files, err := ioutil.ReadDir("/dev/" + p.vgname)
if err != nil {
log.Errorln(err)
return nil
}
parts := []*kvmpart.SKVMGuestDiskPartition{}
for _, f := range files {
partPath := fmt.Sprintf("/dev/%s/%s", p.vgname, f.Name())
@@ -168,11 +167,15 @@ func (p *SKVMGuestLVMPartition) PutdownDevice() bool {
}
func (p *SKVMGuestLVMPartition) isVgActive() bool {
if fileutils2.Exists("/dev/" + p.vgname) {
return true
} else {
return false
for i := 0; i < 3; i++ {
if fileutils2.Exists("/dev/" + p.vgname) {
log.Infof("vg %s is active", p.vgname)
return true
}
time.Sleep(time.Second * 1)
}
log.Infof("vg %s is not active", p.vgname)
return false
}
func (p *SKVMGuestLVMPartition) vgActivate(activate bool) bool {
@@ -185,6 +188,9 @@ func (p *SKVMGuestLVMPartition) vgActivate(activate bool) bool {
log.Errorf("%s", output)
return false
}
if out, err := procutils.NewCommand("vgchange", "--refresh").Output(); err != nil {
log.Errorf("vgchange refresh failed: %s, %s", out, err)
}
return true
}