diff --git a/internal/rbd/replicationcontrollerserver.go b/internal/rbd/replicationcontrollerserver.go index e93887686..7393c2fdd 100644 --- a/internal/rbd/replicationcontrollerserver.go +++ b/internal/rbd/replicationcontrollerserver.go @@ -856,12 +856,13 @@ func checkVolumeResyncStatus(localStatus librbd.SiteMirrorImageStatus) error { // If the state is Replaying means the resync is going on. // Once the volume on remote cluster is demoted and resync - // is completed the image state will be moved to UNKNOWN . - if localStatus.State != librbd.MirrorImageStatusStateReplaying && - localStatus.State != librbd.MirrorImageStatusStateUnknown { + // is completed the image state will be moved to UNKNOWN. + // RBD mirror daemon should be always running on the primary cluster. + if !localStatus.Up || (localStatus.State != librbd.MirrorImageStatusStateReplaying && + localStatus.State != librbd.MirrorImageStatusStateUnknown) { return fmt.Errorf( - "not resyncing. image is in %q state", - localStatus.State) + "not resyncing. Local status: daemon up=%t image is in %q state", + localStatus.Up, localStatus.State) } return nil diff --git a/internal/rbd/replicationcontrollerserver_test.go b/internal/rbd/replicationcontrollerserver_test.go index 401292587..e10d35249 100644 --- a/internal/rbd/replicationcontrollerserver_test.go +++ b/internal/rbd/replicationcontrollerserver_test.go @@ -212,10 +212,19 @@ func TestCheckVolumeResyncStatus(t *testing.T) { args librbd.SiteMirrorImageStatus wantErr bool }{ + { + name: "test when rbd mirror daemon is not running", + args: librbd.SiteMirrorImageStatus{ + State: librbd.MirrorImageStatusStateUnknown, + Up: false, + }, + wantErr: true, + }, { name: "test for unknown state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateUnknown, + Up: true, }, wantErr: false, }, @@ -223,6 +232,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for error state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateError, + Up: true, }, wantErr: true, }, @@ -230,6 +240,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for syncing state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateSyncing, + Up: true, }, wantErr: true, }, @@ -237,6 +248,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for starting_replay state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateStartingReplay, + Up: true, }, wantErr: true, }, @@ -244,6 +256,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for replaying state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateReplaying, + Up: true, }, wantErr: false, }, @@ -251,6 +264,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for stopping_replay state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateStoppingReplay, + Up: true, }, wantErr: true, }, @@ -258,6 +272,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for stopped state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusStateStopped, + Up: true, }, wantErr: true, }, @@ -265,6 +280,7 @@ func TestCheckVolumeResyncStatus(t *testing.T) { name: "test for invalid state", args: librbd.SiteMirrorImageStatus{ State: librbd.MirrorImageStatusState(100), + Up: true, }, wantErr: true, },