fix: error returned by host storage sync was overwritten (#17961)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2023-09-10 00:28:33 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 613d085d20
commit 12a4309be4
+12 -5
View File
@@ -262,8 +262,13 @@ func (s *SLocalStorage) SyncStorageInfo() (jsonutils.JSONObject, error) {
res, err = modules.Storages.Put(
hostutils.GetComputeSession(context.Background()),
s.StorageId, content)
if err != nil {
log.Errorf("SyncStorageInfo Failed: %s: %s", content, err)
return nil, errors.Wrapf(err, "Storages.Put %s", s.StorageId)
}
} else {
mediumType, err := s.GetMediumType()
var mediumType string
mediumType, err = s.GetMediumType()
if err != nil {
log.Errorf("failed get medium type %s %s", s.GetPath(), err)
} else {
@@ -272,11 +277,13 @@ func (s *SLocalStorage) SyncStorageInfo() (jsonutils.JSONObject, error) {
res, err = modules.Storages.Create(
hostutils.GetComputeSession(context.Background()), content)
if err != nil {
log.Errorf("SyncStorageInfo Failed: %s: %s", content, err)
return nil, errors.Wrapf(err, "Storages.Create %s", content)
}
}
if err != nil {
log.Errorf("SyncStorageInfo Failed: %s: %s", content, err)
}
return res, err
return res, nil
}
func (s *SLocalStorage) GetDiskById(diskId string) (IDisk, error) {