From 417f9f2030de3b47dd0f761ae25d81ece107c2f1 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 2 Jun 2022 11:06:14 +0530 Subject: [PATCH] cephfs: skip NetNamespaceFilePath if the volume is pre-provisioned In case of pre-provisioned volume the clusterID is not set in the volume context as the clusterID is missing we cannot extract the NetNamespaceFilePath from the configuration file. For static volume and dynamically provisioned volume the clusterID is set. Note:- This is a special case to support mounting PV without clusterID parameter. Signed-off-by: Madhu Rajanna (cherry picked from commit c9943320ace5792f8549e85fb6a6121ba68aaf70) --- internal/cephfs/nodeserver.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/cephfs/nodeserver.go b/internal/cephfs/nodeserver.go index fdadb6497..65c1aa3d1 100644 --- a/internal/cephfs/nodeserver.go +++ b/internal/cephfs/nodeserver.go @@ -126,12 +126,18 @@ func (ns *NodeServer) NodeStageVolume( } defer volOptions.Destroy() - volOptions.NetNamespaceFilePath, err = util.GetCephFSNetNamespaceFilePath( - util.CsiConfigFile, - volOptions.ClusterID) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + // Skip extracting NetNamespaceFilePath if the clusterID is empty. + // In case of pre-provisioned volume the clusterID is not set in the + // volume context. + if volOptions.ClusterID != "" { + volOptions.NetNamespaceFilePath, err = util.GetCephFSNetNamespaceFilePath( + util.CsiConfigFile, + volOptions.ClusterID) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } } + mnt, err := mounter.New(volOptions) if err != nil { log.ErrorLog(ctx, "failed to create mounter for volume %s: %v", volID, err)