Code change:
} klog.V(5).Infof("iscsi: AttachDisk devicePath: %s", devicePath) <del> // run global mount path related operations based on volumeMode return globalPDPathOperation(b)(b, devicePath, util) </del> <ins> if err = util.persistISCSI(b); err != nil { // Return uncertain error so kubelet calls Unmount / Unmap when the pod // is deleted. return "", types.NewUncertainProgressError(err.Error()) } return devicePath, nil </ins> } <del> // globalPDPathOperation returns global mount path related operations based on volumeMode. // If the volumeMode is 'Filesystem' or not defined, plugin needs to create a dir, persist // iscsi configurations, and then format/mount the volume. // If the volumeMode is 'Block', plugin creates a dir and persists iscsi configurations. // Since volume type is block, plugin doesn't need to format/mount the volume. func globalPDPathOperation(b iscsiDiskMounter) func(iscsiDiskMounter, string, *ISCSIUtil) (string, error) { </del> <ins> // persistISCSI saves iSCSI volume configuration for DetachDisk into global // mount / map directory. func (util *ISCSIUtil) persistISCSI(b iscsiDiskMounter) error { </ins> klog.V(5).Infof("iscsi: AttachDisk volumeMode: %s", b.volumeMode) <ins> var globalPDPath string </ins> if b.volumeMode == v1.PersistentVolumeBlock { <del> // If the volumeMode is 'Block', plugin don't need to format the volume. return func(b iscsiDiskMounter, devicePath string, util *ISCSIUtil) (string, error) { globalPDPath := b.manager.MakeGlobalVDPDName(*b.iscsiDisk) // Create dir like /var/lib/kubelet/plugins/kubernetes.io/iscsi/volumeDevices/{ifaceName}/{portal-some_iqn-lun-lun_id} if err := os.MkdirAll(globalPDPath, 0750); err != nil { klog.Errorf("iscsi: failed to mkdir %s, error", globalPDPath) return "", err } // Persist iscsi disk config to json file for DetachDisk path util.persistISCSI(*(b.iscsiDisk), globalPDPath) return devicePath, nil } </del> <ins> globalPDPath = b.manager.MakeGlobalVDPDName(*b.iscsiDisk) } else { globalPDPath = b.manager.MakeGlobalPDName(*b.iscsiDisk) </ins> } <del> // If the volumeMode is 'Filesystem', plugin needs to format the volume // and mount it to globalPDPath. return func(b iscsiDiskMounter, devicePath string, util *ISCSIUtil) (string, error) { globalPDPath := b.manager.MakeGlobalPDName(*b.iscsiDisk) notMnt, err := b.mounter.IsLikelyNotMountPoint(globalPDPath) if err != nil && !os.IsNotExist(err) { return "", fmt.Errorf("Heuristic determination of mount point failed:%v", err) } // Return confirmed devicePath to caller if !notMnt { klog.Infof("iscsi: %s already mounted", globalPDPath) return devicePath, nil } // Create dir like /var/lib/kubelet/plugins/kubernetes.io/iscsi/{ifaceName}/{portal-some_iqn-lun-lun_id} if err := os.MkdirAll(globalPDPath, 0750); err != nil { klog.Errorf("iscsi: failed to mkdir %s, error", globalPDPath) return "", err } // Persist iscsi disk config to json file for DetachDisk path util.persistISCSI(*(b.iscsiDisk), globalPDPath) err = b.mounter.FormatAndMount(devicePath, globalPDPath, b.fsType, nil) if err != nil { klog.Errorf("iscsi: failed to mount iscsi volume %s [%s] to %s, error %v", devicePath, b.fsType, globalPDPath, err) } return devicePath, nil </del> <ins> if err := os.MkdirAll(globalPDPath, 0750); err != nil { klog.Errorf("iscsi: failed to mkdir %s, error", globalPDPath) return err </ins> } <ins> // Persist iscsi disk config to json file for DetachDisk path return util.persistISCSIFile(*(b.iscsiDisk), globalPDPath) </ins> } // Delete 1 block device of the form "sd*"

Related discussion:
text: What happened: An iSCSI PV with is mounted without these options. What you expected to happen: The volume is mounted with . Anything else we need to know?: iSCSI volume is mounted in and passes as : This can be fixed trivially, however, why is it mounted in at all? There is another mount attempt in , with correct mount options: This code is skipped, because the volume is already mounted. Environment: Kubernetes version (use ): today's master, v1.19.0-alpha.0.781+-dirty , do you remember why we mount stuff in ? iSCSI and FibreChannel does so, the others don't.
/sig storage