controller: check if engine is restoring before running incremental restoration
Longhorn issue 549
@@ -663,6 +663,7 @@ func (m *EngineMonitor) refresh(engine *longhorn.Engine) error {
engine.Status.ReplicaModeMap = currentReplicaModeMap
}
+ needRestore := false
if engine.Status.LastRestoredBackup != "" {
info, err := client.Info()
if err != nil {
@@ -672,6 +673,9 @@ func (m *EngineMonitor) refresh(engine *longhorn.Engine) error {
if info.LastRestored != "" {
engine.Status.LastRestoredBackup = info.LastRestored
}
+ if !info.IsRestoring && engine.Spec.RequestedBackupRestore != engine.Status.LastRestoredBackup {
+ needRestore = true
+ }
}
engine, err = m.ds.UpdateEngine(engine)
@@ -679,8 +683,15 @@ func (m *EngineMonitor) refresh(engine *longhorn.Engine) error {
return err
}
+ if !needRestore {
+ return nil
+ }
+
go func(client engineapi.EngineClient, engine *longhorn.Engine) {
- if engine.Spec.RequestedBackupRestore != "" && engine.Spec.RequestedBackupRestore != engine.Status.LastRestoredBackup {
+ if engine.Spec.RequestedBackupRestore == "" || engine.Spec.RequestedBackupRestore == engine.Status.LastRestoredBackup {
+ return
+ }
+
backupTarget, err := manager.GenerateBackupTarget(m.ds)
if err != nil {
logrus.Errorf("cannot generate BackupTarget for engine %v: %v", engine.Name, err)
@@ -702,7 +713,6 @@ func (m *EngineMonitor) refresh(engine *longhorn.Engine) error {
logrus.Errorf("failed to do update engine %v after incremental restoration: %v", engine.Name, err)
return
}
- }
}(client, engine)
return nil
