diff --git a/build/docker/Dockerfile.host-deployer b/build/docker/Dockerfile.host-deployer index 9f9e5b05c2..1be3282bbc 100644 --- a/build/docker/Dockerfile.host-deployer +++ b/build/docker/Dockerfile.host-deployer @@ -1,4 +1,4 @@ -FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:1.0 +FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:1.1 MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com" diff --git a/pkg/hostman/diskutils/nbd/lvmutils.go b/pkg/hostman/diskutils/nbd/lvmutils.go index 1b91d842ad..ccb61fbd88 100644 --- a/pkg/hostman/diskutils/nbd/lvmutils.go +++ b/pkg/hostman/diskutils/nbd/lvmutils.go @@ -120,8 +120,15 @@ func findVg(partDev string) (SVG, error) { if err != nil { return SVG{}, errors.Wrapf(err, "unable to exec command %q", command) } - log.Debugf("command: %s\noutput: %s", command, output) - lines := strings.Split(strings.TrimSpace(string(output)), "\n") + log.Debugf("command: %s\noutptu: %s", command, output) + + outputStr := string(output) + r := regexp.MustCompile("WARNING: Device mismatch detected for .* which is accessing .* instead of .*.") + ret := r.FindStringSubmatch(outputStr) + if len(ret) > 0 { + return SVG{}, fmt.Errorf("VG conflicts with the VG UUID of the host") + } + lines := strings.Split(strings.TrimSpace(outputStr), "\n") if len(lines) <= 1 { return SVG{}, fmt.Errorf("unable to find vg, output is %q", output) } @@ -176,6 +183,7 @@ func (p *SKVMGuestLVMPartition) FindPartitions() []*kvmpart.SKVMGuestDiskPartiti log.Errorf("unable to readir /dev/%s: %v", p.vgname, err) return nil } + log.Debugf("unable to read dir '/dev/%s': %v", p.vgname, err) // try /dev/mapper/{vgname}-{lvname} lvs, err := p.lvs() if err != nil { @@ -249,7 +257,7 @@ func (p *SKVMGuestLVMPartition) vgActivate(activate bool) bool { } func (p *SKVMGuestLVMPartition) vgRename(oldname, newname string) bool { - command := procutils.NewCommand("vgrename", oldname, newname) + command := procutils.NewCommand("vgrename", "--devices", p.partDev, oldname, newname) output, err := command.Output() if err != nil { log.Errorf("unable to exec command: %q, error: %v, output: %q", command, err, output) diff --git a/pkg/hostman/hostdeployer/deployserver/deployserver.go b/pkg/hostman/hostdeployer/deployserver/deployserver.go index d9a8cdbfc4..ab1622be19 100644 --- a/pkg/hostman/hostdeployer/deployserver/deployserver.go +++ b/pkg/hostman/hostdeployer/deployserver/deployserver.go @@ -360,6 +360,12 @@ func (s *SDeployService) PrepareEnv() error { sysutils.SetSysConfig(nbdBdi+"min_ratio", "0") } + // create /dev/lvm_remote + err = s.checkLvmRemote() + if err != nil { + return errors.Wrap(err, "unable to checkLvmRemote") + } + if !winutils.CheckTool(DeployOption.ChntpwPath) { if winutils.CheckTool("/usr/bin/chntpw.static") { winutils.SetChntpwPath("/usr/bin/chntpw.static") @@ -372,6 +378,21 @@ func (s *SDeployService) PrepareEnv() error { return nil } +func (s *SDeployService) checkLvmRemote() error { + _, err := os.Stat("/dev/lvm_remote") + if err == nil { + return nil + } + if os.IsNotExist(err) { + err := os.Mkdir("/dev/lvm_remote", os.ModePerm) + if err != nil { + return err + } + return nil + } + return err +} + func (s *SDeployService) InitService() { log.Infof("exec socket path: %s", DeployOption.ExecutorSocketPath) if DeployOption.EnableRemoteExecutor {