From 1f2d2863b43a8d802bdcc3524190a40e3cff176c Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:23:15 +0800 Subject: [PATCH] fix(region): lvm disk path add dev prefix (#22105) --- pkg/apis/compute/storage_const.go | 1 + pkg/compute/models/disks.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index d8bd8cd235..8f888277e4 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -181,6 +181,7 @@ var ( SHARED_FILE_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS} FIEL_STORAGE = []string{STORAGE_LOCAL, STORAGE_NFS, STORAGE_GPFS, STORAGE_LVM, STORAGE_CLVM, STORAGE_SLVM} + LVM_STORAGE = []string{STORAGE_LVM, STORAGE_CLVM, STORAGE_SLVM} // supported shared storage types SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD, STORAGE_CLVM, STORAGE_SLVM} diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index 1b2e6b631e..011e4c800a 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -1384,15 +1384,22 @@ func (self *SDisk) GetCloudprovider() *SCloudprovider { } func (self *SDisk) GetPathAtHost(host *SHost) string { + usedStorageId := self.StorageId hostStorage := host.GetHoststorageOfId(self.StorageId) - if hostStorage != nil { - return path.Join(hostStorage.MountPoint, self.Id) - } else if len(self.BackupStorageId) > 0 { + if hostStorage == nil { hostStorage = host.GetHoststorageOfId(self.BackupStorageId) if hostStorage != nil { - return path.Join(hostStorage.MountPoint, self.Id) + usedStorageId = self.BackupStorageId } } + if hostStorage != nil { + storage := StorageManager.FetchStorageById(usedStorageId) + hostpath := path.Join(hostStorage.MountPoint, self.Id) + if storage != nil && utils.IsInStringArray(storage.StorageType, api.LVM_STORAGE) { + hostpath = path.Join("/dev", hostpath) + } + return hostpath + } return "" }