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>
(cherry picked from commit c9943320ac)
This commit is contained in:
Madhu Rajanna 2022-06-02 11:06:14 +05:30 committed by mergify[bot]
parent 67793ecff6
commit 417f9f2030

View File

@ -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)