@@ -68,6 +68,8 @@ const (
6868 tokenServerSidecarMinVersion = "v1.12.2-gke.0" // #nosec G101
6969)
7070
71+ var volumeIDRegEx = regexp .MustCompile (`:.*$` )
72+
7173func NewVolumeCapabilityAccessMode (mode csi.VolumeCapability_AccessMode_Mode ) * csi.VolumeCapability_AccessMode {
7274 return & csi.VolumeCapability_AccessMode {Mode : mode }
7375}
@@ -272,13 +274,14 @@ func parseRequestArguments(req *csi.NodePublishVolumeRequest) (string, string, [
272274
273275 vc := req .GetVolumeContext ()
274276 bucketName := req .GetVolumeId ()
277+
275278 if vc [VolumeContextKeyEphemeral ] == util .TrueStr {
276279 bucketName = vc [VolumeContextKeyBucketName ]
277280 if len (bucketName ) == 0 {
278281 return "" , "" , nil , false , false , fmt .Errorf ("NodePublishVolume VolumeContext %q must be provided for ephemeral storage" , VolumeContextKeyBucketName )
279282 }
280283 }
281-
284+ bucketName = parseVolumeID ( bucketName )
282285 fuseMountOptions := []string {}
283286 if req .GetReadonly () {
284287 fuseMountOptions = joinMountOptions (fuseMountOptions , []string {"ro" })
@@ -302,6 +305,13 @@ func parseRequestArguments(req *csi.NodePublishVolumeRequest) (string, string, [
302305 return targetPath , bucketName , fuseMountOptions , skipCSIBucketAccessCheck , enableMetricsCollection , nil
303306}
304307
308+ // The format allows customers to specify a fake volume handle for static provisioning,
309+ // enabling multiple PVs in the same pod to mount the same bucket. This prevents Kubelet from
310+ // skipping mounts of volumes with the same volume handle, which can cause the pod to be stuck in container creation.
311+ func parseVolumeID (bucketHandle string ) string {
312+ return volumeIDRegEx .ReplaceAllString (bucketHandle , "" )
313+ }
314+
305315func putExitFile (pod * corev1.Pod , targetPath string ) error {
306316 podIsTerminating := pod .DeletionTimestamp != nil
307317 podRestartPolicyIsNever := pod .Spec .RestartPolicy == corev1 .RestartPolicyNever
0 commit comments