From 1d63c75f0dd224d11282d555f4169c74fc83d1bf Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:40:41 +0800 Subject: [PATCH] fix(host): thrown errors on disk fromatfs (#23728) --- pkg/hostman/storageman/disk_base.go | 4 +++- pkg/hostman/storageman/disk_local.go | 6 ++++-- pkg/hostman/storageman/disk_lvm.go | 5 ++++- pkg/hostman/storageman/disk_rbd.go | 6 ++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/hostman/storageman/disk_base.go b/pkg/hostman/storageman/disk_base.go index a8f6980d82..9b3280b077 100644 --- a/pkg/hostman/storageman/disk_base.go +++ b/pkg/hostman/storageman/disk_base.go @@ -244,7 +244,7 @@ func ConvertDiskFsFeaturesToDeploy(fsFeatures *api.DiskFsFeatures) *deployapi.Fs return ret } -func (d *SBaseDisk) FormatFs(fsFormat string, fsFeatures *api.DiskFsFeatures, uuid string, diskInfo *deployapi.DiskInfo) { +func (d *SBaseDisk) FormatFs(fsFormat string, fsFeatures *api.DiskFsFeatures, uuid string, diskInfo *deployapi.DiskInfo) error { log.Infof("Make disk %s fs %s, features: %s", uuid, fsFormat, jsonutils.Marshal(fsFeatures)) _, err := deployclient.GetDeployClient().FormatFs( context.Background(), @@ -257,7 +257,9 @@ func (d *SBaseDisk) FormatFs(fsFormat string, fsFeatures *api.DiskFsFeatures, uu ) if err != nil { log.Errorf("Format fs error : %s", err) + return err } + return nil } func (d *SBaseDisk) DiskSnapshot(ctx context.Context, params interface{}) (jsonutils.JSONObject, error) { diff --git a/pkg/hostman/storageman/disk_local.go b/pkg/hostman/storageman/disk_local.go index a2a02156a4..820ec604dd 100644 --- a/pkg/hostman/storageman/disk_local.go +++ b/pkg/hostman/storageman/disk_local.go @@ -220,7 +220,7 @@ func (d *SLocalDisk) Resize(ctx context.Context, params *SDiskResizeInput) (json if err := d.ResizeFs(resizeFsInfo, params.GuestDesc); err != nil { log.Errorf("Resize fs %s fail %s", d.GetPath(), err) - // return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) + return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) } return d.GetDiskDesc(), nil @@ -426,7 +426,9 @@ func (d *SLocalDisk) CreateRaw(ctx context.Context, sizeMB int, diskFormat strin diskInfo.EncryptAlg = string(encryptInfo.Alg) } if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) { - d.FormatFs(fsFormat, fsFeatures, diskId, diskInfo) + if err := d.FormatFs(fsFormat, fsFeatures, diskId, diskInfo); err != nil { + return nil, errors.Wrap(err, "FormatFs") + } } return d.GetDiskDesc(), nil diff --git a/pkg/hostman/storageman/disk_lvm.go b/pkg/hostman/storageman/disk_lvm.go index b3abb30ccc..43d19f3a25 100644 --- a/pkg/hostman/storageman/disk_lvm.go +++ b/pkg/hostman/storageman/disk_lvm.go @@ -151,7 +151,9 @@ func (d *SLVMDisk) CreateRaw(ctx context.Context, sizeMB int, diskFormat string, diskInfo.EncryptAlg = string(encryptInfo.Alg) } if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) { - d.FormatFs(fsFormat, nil, diskId, diskInfo) + if err := d.FormatFs(fsFormat, nil, diskId, diskInfo); err != nil { + return nil, errors.Wrap(err, "FormatFs") + } } return d.GetDiskDesc(), nil } @@ -294,6 +296,7 @@ func (d *SLVMDisk) Resize(ctx context.Context, params *SDiskResizeInput) (jsonut if err := d.ResizeFs(resizeFsInfo, params.GuestDesc); err != nil { log.Errorf("Resize fs %s fail %s", d.GetPath(), err) + return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) } return d.GetDiskDesc(), nil } diff --git a/pkg/hostman/storageman/disk_rbd.go b/pkg/hostman/storageman/disk_rbd.go index 5c051a44d6..8bde45df30 100644 --- a/pkg/hostman/storageman/disk_rbd.go +++ b/pkg/hostman/storageman/disk_rbd.go @@ -132,7 +132,7 @@ func (d *SRBDDisk) Resize(ctx context.Context, params *SDiskResizeInput) (jsonut } if err := d.ResizeFs(resizeFsInfo, params.GuestDesc); err != nil { log.Errorf("Resize fs %s fail %s", d.GetPath(), err) - // return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) + return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) } return d.GetDiskDesc(), nil @@ -228,7 +228,9 @@ func (d *SRBDDisk) CreateRaw(ctx context.Context, sizeMb int, diskFormat string, Path: d.GetPath(), } if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) { - d.FormatFs(fsFormat, nil, diskId, diskInfo) + if err := d.FormatFs(fsFormat, nil, diskId, diskInfo); err != nil { + return nil, errors.Wrap(err, "FormatFs") + } } return d.GetDiskDesc(), nil