Code change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --kubelet panics on creation of inline ephemeral volume with FSType specified. creation of inline ephemeral volume succeeds with FSType specified. no existing isolated test case. Happens during e2e testing of pmem-csi. Kubernetes version (use ): The pmem-csi CI system where this was detected, runs same tests on k8s systems with 1.19 and 1.20. The problem occurs in testing on 1.20 system, problem does not occur on 1.19 system.Cloud provider or hardware configuration: pmem-csi tests run on cluster formed by few qemu-based systems running Fedora-33 and emulated pmem storage. The issue has been seen in e2e testing in , where a new test was recently introduced that creates a pod with an inline ephemeral volume. If the related VolumeSource has filesystem type set to empty "", or FSType is omitted in spec, then the pod creation works OK. In that case, pmem-csi chooses it's default fstype which is . Example of working definition of VolumeSource: If the filesystem type in the VolumeSource is set to or then kubelet fails to create the volume and pod. A panic trace is written in the node kubelet log and the creation will be retried few times, On pmem-csi side: the 1st NodePublishVolume is received, namespace and volume are created, formatted with mkfs, mounted and NodePublishVolume returns OK. Same request is received few times with increasing time interval. e2e testing code which tries to create the pod, will fail with:
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/assign
/sig node storage
... and ownership changed for those volumes.

Related discussion:
text: }) } } <ins> func Test_csiMountMgr_supportsFSGroup(t *testing.T) { type fields struct { plugin              *csiPlugin driverName          csiDriverName volumeLifecycleMode storage.VolumeLifecycleMode fsGroupPolicy       storage.FSGroupPolicy volumeID            string specVolumeID        string readOnly            bool supportsSELinux     bool spec                *volume.Spec pod                 *api.Pod podUID              types.UID publishContext      map[string]string kubeVolHost         volume.KubeletVolumeHost MetricsProvider     volume.MetricsProvider } type args struct { fsType       string fsGroup      *int64 driverPolicy storage.FSGroupPolicy } tests := []struct { name   string fields fields args   args want   bool }{ { name: "empty all", args: args{}, want: false, }, { name: "driverPolicy is FileFSGroupPolicy", args: args{ fsGroup:      new(int64), driverPolicy: storage.FileFSGroupPolicy, }, want: true, }, { name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy", args: args{ fsGroup:      new(int64), driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy, }, want: false, }, { name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy with empty Spec", args: args{ fsGroup:      new(int64), fsType:       "ext4", driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy, }, fields: fields{ spec: &volume.Spec{}, }, want: false, }, { name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy with empty PersistentVolume", args: args{ fsGroup:      new(int64), fsType:       "ext4", driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy, }, fields: fields{ spec: volume.NewSpecFromPersistentVolume(&corev1.PersistentVolume{}, true), }, want: false, }, { name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy with empty AccessModes", args: args{ fsGroup:      new(int64), fsType:       "ext4", driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy, }, fields: fields{ spec: volume.NewSpecFromPersistentVolume(&api.PersistentVolume{ Spec: api.PersistentVolumeSpec{ AccessModes: []api.PersistentVolumeAccessMode{}, }, }, true), }, want: false, }, { name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy with ReadWriteOnce AccessModes", args: args{ fsGroup:      new(int64), fsType:       "ext4", driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy, }, fields: fields{ spec: volume.NewSpecFromPersistentVolume(&api.PersistentVolume{ Spec: api.PersistentVolumeSpec{ AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce}, }, }, true), }, want: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { c := &csiMountMgr{ plugin:              tt.fields.plugin, driverName:          tt.fields.driverName, volumeLifecycleMode: tt.fields.volumeLifecycleMode, fsGroupPolicy:       tt.fields.fsGroupPolicy, volumeID:            tt.fields.volumeID, specVolumeID:        tt.fields.specVolumeID, readOnly:            tt.fields.readOnly, supportsSELinux:     tt.fields.supportsSELinux, spec:                tt.fields.spec, pod:                 tt.fields.pod, podUID:              tt.fields.podUID, publishContext:      tt.fields.publishContext, kubeVolHost:         tt.fields.kubeVolHost, MetricsProvider:     tt.fields.MetricsProvider, } if got := c.supportsFSGroup(tt.args.fsType, tt.args.fsGroup, tt.args.driverPolicy); got != tt.want { t.Errorf("supportsFSGroup() = %v, want %v", got, tt.want) } }) } } </ins>