manager: Put API backup call into goroutine
So it won't block the UI.
@@ -160,9 +160,9 @@ func (m *VolumeManager) BackupSnapshot(snapshotName string, labels map[string]st
if err != nil {
return err
}
- //TODO time consuming operation, move it out of API server path
+ go func() {
if err := engine.SnapshotBackup(snapshotName, backupTarget, labels, credential); err != nil {
- return err
+ logrus.Errorf("Failed to backup snapshot %v with label %v for volume %v: %v", snapshotName, labels, volumeName, err)
}
logrus.Debugf("Backup snapshot %v with label %v for volume %v", snapshotName, labels, volumeName)
@@ -173,6 +173,7 @@ func (m *VolumeManager) BackupSnapshot(snapshotName string, labels map[string]st
if err := UpdateVolumeLastBackup(volumeName, target, m.ds.GetVolume, m.ds.UpdateVolume); err != nil {
logrus.Warnf("Failed to update volume LastBackup for %v: %v", volumeName, err)
}
+ }()
return nil
}
