fix(region,host-deployer): qga os distribution format (#19110)

host-deployer fix xfs mount error

Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
wanyaoqi
2023-12-26 20:15:26 +08:00
committed by GitHub
parent 7f2ff35da4
commit d5b3acfc87
2 changed files with 30 additions and 4 deletions
@@ -76,10 +76,34 @@ func (self *GuestQgaSyncOsInfoTask) updateOsInfo(ctx context.Context, guest *mod
if osInfo.Id == "mswindows" {
osType = "Windows"
}
osDistribution := osInfo.PrettyName
switch osInfo.Id {
case "centos":
osDistribution = "CentOS"
case "debian":
osDistribution = "Debian"
case "ubuntu":
osDistribution = "Ubuntu"
case "fedora":
osDistribution = "Fedora"
case "openEuler":
osDistribution = "OpenEuler"
case "gentoo":
osDistribution = "Gentoo"
case "cirros":
osDistribution = "Cirros"
case "archLinux":
osDistribution = "ArchLinux"
case "kylin":
osDistribution = "Kylin"
case "anolis":
osDistribution = "Anolis"
}
osInput := api.ServerSetOSInfoInput{
Type: osType,
Distribution: osInfo.PrettyName,
Version: osInfo.Version,
Distribution: osDistribution,
Version: osInfo.VersionId,
Arch: osInfo.Machine,
}
_, err = guest.PerformSetOsInfo(ctx, self.UserCred, nil, osInput)
+4 -2
View File
@@ -177,13 +177,14 @@ func (p *SKVMGuestDiskPartition) mount(readonly bool) error {
cmds = append(cmds, p.partDev, p.mountPath)
var err error
var mountSuccess = false
if fsType == "xfs" {
uuids, _ := fileutils2.GetDevUuid(p.partDev)
p.uuid = uuids["UUID"]
if len(p.uuid) > 0 {
xfsutils.LockXfsPartition(p.uuid)
defer func() {
if err != nil {
if !mountSuccess {
xfsutils.UnlockXfsPartition(p.uuid)
}
}()
@@ -203,7 +204,7 @@ func (p *SKVMGuestDiskPartition) mount(readonly bool) error {
}
}()
select {
case err := <-errChan:
case err = <-errChan:
if err != nil {
return false, err
}
@@ -226,6 +227,7 @@ func (p *SKVMGuestDiskPartition) mount(readonly bool) error {
if err != nil {
return errors.Wrap(err, "mount failed")
}
mountSuccess = true
return nil // errors.Wrapf(err, "mount failed: %s", output)
}