mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(region): add reason when syning status for backup storage
This commit is contained in:
@@ -1433,7 +1433,8 @@ func (self *SKVMRegionDriver) RequestSyncBackupStorageStatus(ctx context.Context
|
||||
return nil, err
|
||||
}
|
||||
status, _ := res.GetString("status")
|
||||
return nil, bs.SetStatus(userCred, status, "sync status")
|
||||
reason, _ := res.GetString("reason")
|
||||
return nil, bs.SetStatus(userCred, status, reason)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ type IBackupStorage interface {
|
||||
ConvertFrom(srcPath string, format qemuimg.TImageFormat, backupId string) (int, error)
|
||||
InstancePack(packageName string, backupIds []string, metadata *api.InstanceBackupPackMetadata) error
|
||||
InstanceUnpack(packageName string) ([]string, *api.InstanceBackupPackMetadata, error)
|
||||
IsOnline() (bool, error)
|
||||
IsOnline() (bool, string, error)
|
||||
}
|
||||
|
||||
var backupStoragePool *sync.Map = &sync.Map{}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (s *SNFSBackupStorage) checkAndMount() error {
|
||||
err := procutils.NewRemoteCommandContextAsFarAsPossible(ctx,
|
||||
"mount", "-t", "nfs", fmt.Sprintf("%s:%s", s.NfsHost, s.NfsSharedDir), s.Path).Run()
|
||||
if err != nil {
|
||||
return ErrorBackupStorageOffline
|
||||
return errors.Wrap(ErrorBackupStorageOffline, err.Error())
|
||||
}
|
||||
backupDir := s.getBackupDir()
|
||||
if !fileutils2.Exists(backupDir) {
|
||||
@@ -462,14 +462,14 @@ func (s *SNFSBackupStorage) IsExists(backupId string) (bool, error) {
|
||||
return fileutils2.Exists(filename), nil
|
||||
}
|
||||
|
||||
func (s *SNFSBackupStorage) IsOnline() (bool, error) {
|
||||
func (s *SNFSBackupStorage) IsOnline() (bool, string, error) {
|
||||
err := s.checkAndMount()
|
||||
if errors.Cause(err) == ErrorBackupStorageOffline {
|
||||
return false, nil
|
||||
return false, err.Error(), nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, "", err
|
||||
}
|
||||
s.unMount()
|
||||
return true, nil
|
||||
return true, "", nil
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func storageSyncBackupStorage(ctx context.Context, w http.ResponseWriter, r *htt
|
||||
hostutils.Response(ctx, w, err)
|
||||
return
|
||||
}
|
||||
exist, err := backupStorage.IsOnline()
|
||||
exist, reason, err := backupStorage.IsOnline()
|
||||
if err != nil {
|
||||
hostutils.Response(ctx, w, err)
|
||||
return
|
||||
@@ -275,6 +275,7 @@ func storageSyncBackupStorage(ctx context.Context, w http.ResponseWriter, r *htt
|
||||
status = compute.BACKUPSTORAGE_STATUS_OFFLINE
|
||||
}
|
||||
ret.Set("status", jsonutils.NewString(status))
|
||||
ret.Set("reason", jsonutils.NewString(reason))
|
||||
hostutils.Response(ctx, w, ret)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user