From d39bf748519c631a356f63be8ec64a74483465f7 Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Mon, 24 Aug 2026 14:36:57 +0800 Subject: [PATCH] fix(host): guest desc correct rbd disk path (#25394) --- .../storageman/diskhandlers/diskhandler.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/hostman/storageman/diskhandlers/diskhandler.go b/pkg/hostman/storageman/diskhandlers/diskhandler.go index a4bebc39ac..801773cf30 100644 --- a/pkg/hostman/storageman/diskhandlers/diskhandler.go +++ b/pkg/hostman/storageman/diskhandlers/diskhandler.go @@ -32,6 +32,7 @@ import ( deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" "yunion.io/x/onecloud/pkg/hostman/hostutils" "yunion.io/x/onecloud/pkg/hostman/storageman" + "yunion.io/x/onecloud/pkg/hostman/storageman/lvmutils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" @@ -349,6 +350,36 @@ func diskResize(ctx context.Context, userCred mcclient.TokenCredential, storage if !ok { return nil, hostutils.ParamsError } + + if input.GuestDesc != nil { + disks := input.GuestDesc.Disks + var diskPaths = make([]string, len(disks)) + for i := range disks { + diskPath := disks[i].Path + diskPaths[i] = diskPath + // GetDiskByPath will probe disks + disk, err := storageman.GetManager().GetDiskByPath(diskPath) + if err != nil { + return nil, errors.Wrapf(err, "GetDiskByPath(%s)", diskPath) + } + disks[i].Path = disk.GetPath() + } + defer func() { + for i := range diskPaths { + diskPath := diskPaths[i] + disks[i].Path = diskPath + disk, e := storageman.GetManager().GetDiskByPath(diskPath) + if e != nil { + log.Errorf("failed get disk bypath %s %s", diskPath, e) + } + if utils.IsInStringArray(disk.GetType(), []string{compute.STORAGE_SLVM, compute.STORAGE_CLVM}) { + if errDeactive := lvmutils.LVDeactivate(diskPath); err != nil { + log.Errorf("failed deactive disk %s: %s", diskPath, errDeactive) + } + } + } + }() + } return disk.Resize(ctx, input) } hostutils.DelayTask(ctx, resizeFunc, resizeDiskInfo)