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 <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2022-06-02 11:06:14 +05:30 committed by mergify[bot]
parent f250a09c47
commit c9943320ac

View File

@ -126,12 +126,18 @@ func (ns *NodeServer) NodeStageVolume(
} }
defer volOptions.Destroy() defer volOptions.Destroy()
volOptions.NetNamespaceFilePath, err = util.GetCephFSNetNamespaceFilePath( // Skip extracting NetNamespaceFilePath if the clusterID is empty.
util.CsiConfigFile, // In case of pre-provisioned volume the clusterID is not set in the
volOptions.ClusterID) // volume context.
if err != nil { if volOptions.ClusterID != "" {
return nil, status.Error(codes.Internal, err.Error()) 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) mnt, err := mounter.New(volOptions)
if err != nil { if err != nil {
log.ErrorLog(ctx, "failed to create mounter for volume %s: %v", volID, err) log.ErrorLog(ctx, "failed to create mounter for volume %s: %v", volID, err)