Skip to content

Commit 9247965

Browse files
committed
ci: extra commit to fix panic
This commit will be removed later Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1 parent 6e5f2b7 commit 9247965

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

internal/csi-addons/rbd/replication.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,9 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context,
863863
remoteStatus, err := mirrorStatus.GetRemoteSiteStatus(ctx)
864864
if err != nil {
865865
log.ErrorLog(ctx, err.Error())
866-
866+
if errors.Is(err, librbd.ErrNotExist) {
867+
return nil, status.Errorf(codes.NotFound, "failed to get remote status: %v", err)
868+
}
867869
return nil, status.Errorf(codes.Internal, "failed to get remote status: %v", err)
868870
}
869871

internal/rbd/group/group_mirror.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,22 @@ func (status globalMirrorGroupStatus) GetRemoteSiteStatus(ctx context.Context) (
331331
totalSnapshotDuration += *localSnapInfo.LastSnapshotDuration
332332
}
333333
err = nil
334-
totalDuration := int64(totalSnapshotDuration / int64(totalImages))
334+
totalDuration := int64(0)
335+
if totalSnapshotDuration > 0 {
336+
totalDuration = int64(totalSnapshotDuration / int64(totalImages))
337+
}
338+
totalTime := int64(0)
339+
if totalSnpshotTime > 0 {
340+
totalTime = int64(totalSnpshotTime / int64(totalImages))
341+
}
342+
totalBytes := int64(0)
343+
if totalSnapshotBytes > 0 {
344+
totalBytes = int64(totalSnapshotBytes / int64(totalImages))
345+
}
335346
// write the total snapshot time, bytes and duration to the description
336347
d := localStatus{
337-
LocalSnapshotTime: int64(totalSnpshotTime / int64(totalImages)),
338-
LastSnapshotBytes: int64(totalSnapshotBytes / int64(totalImages)),
348+
LocalSnapshotTime: totalTime,
349+
LastSnapshotBytes: totalBytes,
339350
LastSnapshotDuration: &totalDuration,
340351
}
341352
description, err := json.Marshal(d)

0 commit comments

Comments
 (0)