From 31da09863e317efb57a84bf3137f9e6a57f03894 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 24 Apr 2025 17:15:02 +0200 Subject: [PATCH] rbd: do not resize read-only volumes while staging Volumes that were requested with a read-only capability should not be resized. Reported-by: Alex Kalenyuk Signed-off-by: Niels de Vos --- internal/rbd/nodeserver.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/rbd/nodeserver.go b/internal/rbd/nodeserver.go index eaa75d599..ca75c8187 100644 --- a/internal/rbd/nodeserver.go +++ b/internal/rbd/nodeserver.go @@ -474,13 +474,16 @@ func (ns *NodeServer) stageTransaction( } } - // As we are supporting the restore of a volume to a bigger size and - // creating bigger size clone from a volume, we need to check filesystem - // resize is required, if required resize filesystem. - // in case of encrypted block PVC resize only the LUKS device. - err = resizeNodeStagePath(ctx, isBlock, transaction, req.GetVolumeId(), stagingTargetPath) - if err != nil { - return transaction, err + // if the volume is read-only, no resize should be done + if !volOptions.readOnly { + // As we are supporting the restore of a volume to a bigger size and + // creating bigger size clone from a volume, we need to check filesystem + // resize is required, if required resize filesystem. + // in case of encrypted block PVC resize only the LUKS device. + err = resizeNodeStagePath(ctx, isBlock, transaction, req.GetVolumeId(), stagingTargetPath) + if err != nil { + return transaction, err + } } return transaction, err