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

@ -335,11 +335,19 @@ func (status SiteMirrorImageStatus) GetLastSyncInfo(ctx context.Context) (types.
}
type syncInfo struct {
LocalSnapshotTime int64 `json:"local_snapshot_timestamp"`
LastSnapshotBytes int64 `json:"last_snapshot_bytes"`
LastSnapshotDuration *int64 `json:"last_snapshot_sync_seconds"`
LocalSnapshotTime int64 `json:"local_snapshot_timestamp"`
LastSnapshotBytes int64 `json:"last_snapshot_bytes"`
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.
var _ types.SyncInfo = &syncInfo{}
@ -401,3 +409,7 @@ func (si *syncInfo) GetLastSyncDuration() *time.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
// optional.
GetLastSyncBytes() int64
// IsSyncing returns true if the SyncInfo for the SiteStatus is actively
// syncing.
IsSyncing() bool
}