diff --git a/internal/csi-addons/rbd/replication.go b/internal/csi-addons/rbd/replication.go index 9c7a68714fe..a59d8fa948d 100644 --- a/internal/csi-addons/rbd/replication.go +++ b/internal/csi-addons/rbd/replication.go @@ -863,7 +863,9 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context, remoteStatus, err := mirrorStatus.GetRemoteSiteStatus(ctx) if err != nil { log.ErrorLog(ctx, err.Error()) - + if errors.Is(err, librbd.ErrNotExist) { + return nil, status.Errorf(codes.NotFound, "failed to get remote status: %v", err) + } return nil, status.Errorf(codes.Internal, "failed to get remote status: %v", err) } diff --git a/internal/rbd/group/group_mirror.go b/internal/rbd/group/group_mirror.go index f4a3a61cf9d..751fd4d67ca 100644 --- a/internal/rbd/group/group_mirror.go +++ b/internal/rbd/group/group_mirror.go @@ -331,11 +331,22 @@ func (status globalMirrorGroupStatus) GetRemoteSiteStatus(ctx context.Context) ( totalSnapshotDuration += *localSnapInfo.LastSnapshotDuration } err = nil - totalDuration := int64(totalSnapshotDuration / int64(totalImages)) + totalDuration := int64(0) + if totalSnapshotDuration > 0 { + totalDuration = int64(totalSnapshotDuration / int64(totalImages)) + } + totalTime := int64(0) + if totalSnpshotTime > 0 { + totalTime = int64(totalSnpshotTime / int64(totalImages)) + } + totalBytes := int64(0) + if totalSnapshotBytes > 0 { + totalBytes = int64(totalSnapshotBytes / int64(totalImages)) + } // write the total snapshot time, bytes and duration to the description d := localStatus{ - LocalSnapshotTime: int64(totalSnpshotTime / int64(totalImages)), - LastSnapshotBytes: int64(totalSnapshotBytes / int64(totalImages)), + LocalSnapshotTime: totalTime, + LastSnapshotBytes: totalBytes, LastSnapshotDuration: &totalDuration, } description, err := json.Marshal(d)