fix(host): thrown errors on disk fromatfs (#23728)

This commit is contained in:
wanyaoqi
2025-11-14 10:40:41 +08:00
committed by GitHub
parent 8d4afe5e56
commit 1d63c75f0d
4 changed files with 15 additions and 6 deletions
+3 -1
View File
@@ -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) {
+4 -2
View File
@@ -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
+4 -1
View File
@@ -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
}
+4 -2
View File
@@ -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