kubernetes/pkg/volume
Yubao Liu 834ce75f88 Make sure auto-mounted subpath mount source is already mounted
For example, we have two filesystems, one is embedded into another:

/a/test		# first filesystem with a directory "/a/test/b2"
/a/test/b2	# not auto mounted yet second filesystem, notice "/a/test/b2" is
	        # a new directory on this filesystem after this filesystem is mounted

For subpath mount "/a/test/b2",  `openat("/a/test", "b2")` gets directory "b2" on the first
filesystem, then "mount -c" will use this wrong directory as source directory.

`fstatat("/a/test", "b2/")` forces triggering auto mount of second filesystem, so
`openat("/a/test", "b2")` gets correct source directory for "mount -c".

This fixes issue https://github.com/kubernetes/kubernetes/issues/110818#issuecomment-1175736550

References:

1. https://man7.org/linux/man-pages/man2/openat.2.html

   If pathname refers to an automount point that has not yet
   been triggered, so no other filesystem is mounted on it,
   then the call returns a file descriptor referring to the
   automount directory without triggering a mount.

2. https://man7.org/linux/man-pages/man2/open_by_handle_at.2.html

   name_to_handle_at() does not trigger a mount when the final
   component of the pathname is an automount point.  When a
   filesystem supports both file handles and automount points, a
   name_to_handle_at() call on an automount point will return with
   error EOVERFLOW without having increased handle_bytes.  This can
   happen since Linux 4.13 with NFS when accessing a directory which
   is on a separate filesystem on the server.  In this case, the
   automount can be triggered by adding a "/" to the end of the
   pathname.
2022-07-12 22:09:11 +08:00
..
awsebs Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
azure_file Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
azuredd Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
cephfs Handle os.MkdirAll error 2022-06-30 16:26:24 +08:00
cinder Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
configmap Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
csi CSIMigration feature gate to GA 2022-06-06 21:19:19 +00:00
csimigration CSIMigration feature gate to GA 2022-06-06 21:19:19 +00:00
downwardapi Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
emptydir Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
fc volume/fc: fix FibreChannel volume plugin matching wrong disks 2022-06-23 16:36:01 +08:00
flexvolume Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
flocker Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
gcepd Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
git_repo Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
glusterfs Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
hostpath Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
iscsi enhance and fix log calls 2022-03-24 11:13:50 +01:00
local Log StructuredLog: spelling formatting 2022-04-26 17:04:06 +08:00
nfs Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
portworx CSIMigration feature gate to GA 2022-06-06 21:19:19 +00:00
projected Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
quobyte Handle os.MkdirAll error 2022-06-30 16:26:24 +08:00
rbd CSIMigration feature gate to GA 2022-06-06 21:19:19 +00:00
secret Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
storageos Update golangci-lint to 1.46.2 and fix errors 2022-06-29 17:42:46 +08:00
testing Merge pull request #99685 from yangjunmyfm192085/run-test24 2022-05-03 17:16:47 -07:00
util Make sure auto-mounted subpath mount source is already mounted 2022-07-12 22:09:11 +08:00
validation hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
vsphere_volume CSIMigration feature gate to GA 2022-06-06 21:19:19 +00:00
doc.go
metrics_block.go add volume type and seperated histogram for volume stat collection 2022-01-19 22:33:37 +08:00
metrics_block_test.go The test was not very useful and required elevated access 2021-06-04 15:48:35 -04:00
metrics_cached.go
metrics_du.go set metric_source to du or fsquota accordingly 2022-01-20 10:56:02 +08:00
metrics_du_test.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
metrics_errors.go Add helper functions for Block volume Capacity detection 2021-05-20 16:37:12 +02:00
metrics_nil.go Add SupportsMetrics() for Block-mode volumes 2021-05-20 17:10:23 +02:00
metrics_nil_test.go Add SupportsMetrics() for Block-mode volumes 2021-05-20 17:10:23 +02:00
metrics_statfs.go add volume type and seperated histogram for volume stat collection 2022-01-19 22:33:37 +08:00
metrics_statfs_test.go
noop_expandable_plugin.go plumb service account token down to csi driver 2020-11-12 09:26:43 -08:00
OWNERS Check in OWNERS modified by update-yamlfmt.sh 2021-12-09 21:31:26 -05:00
plugins.go Merge pull request #109853 from ping035627/k8s-220506 2022-07-01 07:29:22 -07:00
plugins_test.go Fixed a possible nil pointer dereference caused by variable plug 2021-05-21 10:17:04 +08:00
volume.go Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount 2022-02-24 07:56:30 -08:00
volume_linux.go Fix the wrong log 2021-11-17 09:07:07 +08:00
volume_linux_test.go kubelet: Remove the deprecated flag --experimental-check-node-capabilities-before-mount 2022-01-06 11:47:11 +08:00
volume_unsupported.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00