kubernetes/pkg/volume/util
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
..
fs set metric_source to du or fsquota accordingly 2022-01-20 10:56:02 +08:00
fsquota Remove //lint:ignore pragmas that aren't being used anymore 2021-11-17 08:56:54 +01:00
hostutil Remove util/selinux package 2022-02-11 15:20:35 +01:00
nestedpendingoperations Check in OWNERS modified by update-yamlfmt.sh 2021-12-09 21:31:26 -05:00
operationexecutor kubelet: fix volume reconstruction for CSI ephemeral volumes 2022-06-01 14:22:57 -06:00
recyclerclient Move from k8s.gcr.io to registry.k8s.io 2022-05-31 10:16:53 -04:00
subpath Make sure auto-mounted subpath mount source is already mounted 2022-07-12 22:09:11 +08:00
types simplify returning boolean expression in /pkg/volume 2021-05-25 02:39:55 +00:00
volumepathhandler generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
atomic_writer.go subatomic: Creates the symlinks to user-visible files later 2021-01-06 04:10:28 -08:00
atomic_writer_test.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
attach_limit.go Do not make Cinder Max volume predicate a default 2019-01-16 15:17:05 -05:00
attach_limit_test.go Fix compatibility tests for scheduler 2018-09-05 12:29:00 -04:00
device_util.go fix golint issue for pkg/volume/util 2018-09-10 21:24:35 +00:00
device_util_linux.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
device_util_linux_test.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
device_util_unsupported.go generated: Run hack/update-gofmt.sh 2021-08-24 15:47:49 -04:00
doc.go fix golint issue for pkg/volume/util 2018-09-10 21:24:35 +00:00
finalizer.go fix golint issue for pkg/volume/util 2018-09-10 21:24:35 +00:00
io_util.go Avoid deleted iSCSI LUNs in the kernel 2018-07-24 23:58:19 -04:00
metrics.go Merge pull request #105885 from gnufied/move-configurable-fsgroup-ga 2021-11-10 13:53:27 -08:00
metrics_test.go change plugin name in fsgroupapplymetrics of csi and flexvolume to 2020-11-04 16:28:28 +08:00
nested_volumes.go modify static check 2020-09-23 19:27:24 +08:00
nested_volumes_test.go Always use filepath.Join instead of path.Join 2019-04-29 09:56:05 -06:00
resize_util.go Implement controller and kubelet changes for recovery from resize 2021-11-16 11:06:46 -05:00
resize_util_test.go Implement controller and kubelet changes for recovery from resize 2021-11-16 11:06:46 -05:00
util.go Move volume helpers to "k8s.io/component-helpers/storage/volume". 2022-03-16 15:43:09 +08:00
util_test.go Move from k8s.gcr.io to registry.k8s.io 2022-05-31 10:16:53 -04:00