Skip to content

Commit db1f7c8

Browse files
committed
rbd: consider lastSyncTimeNotFound as image not syncing
This commit modifies code to consider image as not syncing when the lastSyncTime is not found. Signed-off-by: Rakshith R <rar@redhat.com>
1 parent 99e93b3 commit db1f7c8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/csi-addons/rbd/replication.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,16 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context,
724724
log.DebugLog(ctx, "image %s, savedImageTime=%v, currentImageTime=%v", rbdVol, st, creationTime)
725725

726726
syncInfo, sErr := localStatus.GetLastSyncInfo(ctx)
727-
if sErr != nil {
727+
if sErr != nil && !errors.Is(sErr, rbderrors.ErrLastSyncTimeNotFound) {
728728
return nil, status.Errorf(codes.Internal, "failed to get last sync info: %s", sErr.Error())
729729
}
730730

731-
if req.GetForce() && st.Equal(*creationTime) && !syncInfo.IsSyncing() {
731+
// consider the image is not syncing if either
732+
// - the last sync time was not found or
733+
// - the sync info indicates the image is not syncing
734+
IsNotSyncing := (errors.Is(sErr, rbderrors.ErrLastSyncTimeNotFound) || !syncInfo.IsSyncing())
735+
736+
if req.GetForce() && st.Equal(*creationTime) && IsNotSyncing {
732737
err = mirror.Resync(ctx)
733738
if err != nil {
734739
return nil, getGRPCError(err)

0 commit comments

Comments
 (0)