From d5b3acfc87dad997c3200724754b5efee21b58e0 Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:15:26 +0800 Subject: [PATCH] fix(region,host-deployer): qga os distribution format (#19110) host-deployer fix xfs mount error Signed-off-by: wanyaoqi --- .../tasks/guest_qga_sync_os_info_task.go | 28 +++++++++++++++++-- pkg/hostman/guestfs/kvmpart/kvmpart.go | 6 ++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/pkg/compute/tasks/guest_qga_sync_os_info_task.go b/pkg/compute/tasks/guest_qga_sync_os_info_task.go index 23c611e093..ff748cc287 100644 --- a/pkg/compute/tasks/guest_qga_sync_os_info_task.go +++ b/pkg/compute/tasks/guest_qga_sync_os_info_task.go @@ -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) diff --git a/pkg/hostman/guestfs/kvmpart/kvmpart.go b/pkg/hostman/guestfs/kvmpart/kvmpart.go index ea62ed29b1..41bfbaeacc 100644 --- a/pkg/hostman/guestfs/kvmpart/kvmpart.go +++ b/pkg/hostman/guestfs/kvmpart/kvmpart.go @@ -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) }