From d7838defcf7bf2060f19aba3ffcded4304a1415c Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 6 Apr 2021 11:18:01 +0530 Subject: [PATCH] rbd: return FailedPrecondition error message In case of the DR the image on the primary site cannot be demoted as the cluster is down, during failover the image need to be force promoted. RBD returns `Device or resource busy` error message if the image cannot be promoted for above reason. Return FailedPrecondition so that replication operator can send request to force promote the image. Signed-off-by: Madhu Rajanna --- internal/rbd/replicationcontrollerserver.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/rbd/replicationcontrollerserver.go b/internal/rbd/replicationcontrollerserver.go index 3cad03d5a..2ac9a232f 100644 --- a/internal/rbd/replicationcontrollerserver.go +++ b/internal/rbd/replicationcontrollerserver.go @@ -299,6 +299,15 @@ func (rs *ReplicationServer) PromoteVolume(ctx context.Context, err = rbdVol.promoteImage(req.Force) if err != nil { util.ErrorLog(ctx, err.Error()) + // In case of the DR the image on the primary site cannot be + // demoted as the cluster is down, during failover the image need + // to be force promoted. RBD returns `Device or resource busy` + // error message if the image cannot be promoted for above reason. + // Return FailedPrecondition so that replication operator can send + // request to force promote the image. + if strings.Contains(err.Error(), "Device or resource busy") { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } return nil, status.Error(codes.Internal, err.Error()) } }