mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-05-22 07:16:41 +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())
|
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)
|
||||||
|
@ -335,11 +335,19 @@ func (status SiteMirrorImageStatus) GetLastSyncInfo(ctx context.Context) (types.
|
|||||||
}
|
}
|
||||||
|
|
||||||
type syncInfo struct {
|
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
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user