rbd: prevent calling mirror.Resync() if the mirror is syncing

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2025-04-15 17:52:30 +02:00 committed by mergify[bot]
parent 04257464bb
commit af4431f60b
3 changed files with 26 additions and 4 deletions

View File

@ -718,7 +718,13 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
return nil, status.Errorf(codes.Internal, "failed to parse image creation time: %s", sErr.Error()) return nil, status.Errorf(codes.Internal, "failed to parse image creation time: %s", sErr.Error())
} }
log.DebugLog(ctx, "image %s, savedImageTime=%v, currentImageTime=%v", rbdVol, st, creationTime) log.DebugLog(ctx, "image %s, savedImageTime=%v, currentImageTime=%v", rbdVol, st, creationTime)
if req.GetForce() && st.Equal(*creationTime) {
syncInfo, sErr := localStatus.GetLastSyncInfo(ctx)
if sErr != nil {
return nil, status.Errorf(codes.Internal, "failed to get last sync info: %s", sErr.Error())
}
if req.GetForce() && st.Equal(*creationTime) && !syncInfo.IsSyncing() {
err = mirror.Resync(ctx) err = mirror.Resync(ctx)
if err != nil { if err != nil {
return nil, getGRPCError(err) return nil, getGRPCError(err)

View File

@ -338,8 +338,16 @@ type syncInfo struct {
LocalSnapshotTime int64 `json:"local_snapshot_timestamp"` LocalSnapshotTime int64 `json:"local_snapshot_timestamp"`
LastSnapshotBytes int64 `json:"last_snapshot_bytes"` LastSnapshotBytes int64 `json:"last_snapshot_bytes"`
LastSnapshotDuration *int64 `json:"last_snapshot_sync_seconds"` LastSnapshotDuration *int64 `json:"last_snapshot_sync_seconds"`
ReplayState replayState `json:"replay_state"`
} }
type replayState string
const (
idle replayState = "idle"
syncing replayState = "syncing"
)
// Type assertion for ensuring an implementation of the full SyncInfo interface. // Type assertion for ensuring an implementation of the full SyncInfo interface.
var _ types.SyncInfo = &syncInfo{} var _ types.SyncInfo = &syncInfo{}
@ -401,3 +409,7 @@ func (si *syncInfo) GetLastSyncDuration() *time.Duration {
return &duration return &duration
} }
func (si *syncInfo) IsSyncing() bool {
return si.ReplayState == syncing
}

View File

@ -110,4 +110,8 @@ type SyncInfo interface {
// case there is no last snapshot bytes returns 0 as the LastSyncBytes is // case there is no last snapshot bytes returns 0 as the LastSyncBytes is
// optional. // optional.
GetLastSyncBytes() int64 GetLastSyncBytes() int64
// IsSyncing returns true if the SyncInfo for the SiteStatus is actively
// syncing.
IsSyncing() bool
} }