From 2f813dac1d60e89b277e654a35a3c97d73f1ffa2 Mon Sep 17 00:00:00 2001
From: yati1998 <ypadia@redhat.com>
Date: Tue, 14 Jan 2025 18:39:27 +0530
Subject: [PATCH] rbd: add check to getVolumeReplicationInfo

this commit adds a check to getVolumeReplicationInfo
to include status not found error while getting the
remote status.
This helps the failover to be done even if remote site status
is not found

Signed-off-by: yati1998 <ypadia@redhat.com>
(cherry picked from commit 4101b63e02f110a30f09a499e31b5ebaaa59cd0e)
---
 internal/csi-addons/rbd/replication.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/internal/csi-addons/rbd/replication.go b/internal/csi-addons/rbd/replication.go
index f87a24401..d0049b725 100644
--- a/internal/csi-addons/rbd/replication.go
+++ b/internal/csi-addons/rbd/replication.go
@@ -876,6 +876,10 @@ func (rs *ReplicationServer) GetVolumeReplicationInfo(ctx context.Context,
 	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)
 	}