@@ -61,6 +61,18 @@ func getVolumeCreator(source *csi.VolumeContentSource, shareOpts *options.Contro
6161 return nil , status .Error (codes .InvalidArgument , "invalid volume content source" )
6262}
6363
64+ func filterParametersForVolumeContext (params map [string ]string , recognizedFields []string ) map [string ]string {
65+ volCtx := make (map [string ]string )
66+
67+ for _ , fieldName := range recognizedFields {
68+ if val , ok := params [fieldName ]; ok {
69+ volCtx [fieldName ] = val
70+ }
71+ }
72+
73+ return volCtx
74+ }
75+
6476func (cs * controllerServer ) CreateVolume (ctx context.Context , req * csi.CreateVolumeRequest ) (* csi.CreateVolumeResponse , error ) {
6577 if err := validateCreateVolumeRequest (req ); err != nil {
6678 return nil , status .Error (codes .InvalidArgument , err .Error ())
@@ -150,17 +162,17 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
150162 accessibleTopology = req .GetAccessibilityRequirements ().GetPreferred ()
151163 }
152164
165+ volCtx := filterParametersForVolumeContext (params , options .NodeVolumeContextFields ())
166+ volCtx ["shareID" ] = share .ID
167+ volCtx ["shareAccessID" ] = accessRight .ID
168+
153169 return & csi.CreateVolumeResponse {
154170 Volume : & csi.Volume {
155171 VolumeId : share .ID ,
156172 ContentSource : req .GetVolumeContentSource (),
157173 AccessibleTopology : accessibleTopology ,
158174 CapacityBytes : int64 (sizeInGiB ) * bytesInGiB ,
159- VolumeContext : map [string ]string {
160- "shareID" : share .ID ,
161- "shareAccessID" : accessRight .ID ,
162- "cephfs-mounter" : shareOpts .CephfsMounter ,
163- },
175+ VolumeContext : volCtx ,
164176 },
165177 }, nil
166178}
0 commit comments