mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-05-21 23:06:42 +00:00
rbd: prevent calling mirror.Resync() if the mirror is syncing
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
04257464bb
commit
af4431f60b
@ -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())
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, getGRPCError(err)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user