kubernetes/pkg/util/mount
Kubernetes Submit Queue 481b2dc7cf
Merge pull request #62102 from cofyc/fixlocalvolumefsgroup
Automatic merge from submit-queue (batch tested with PRs 64013, 63896, 64139, 57527, 62102). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Setup fsGroup for local volumes correctly

**What this PR does / why we need it**:

This pr fixes fsGroup check in local volume in containerized kubelet. Except this, it also fixes fsGroup check when volume source is a normal directory whether kubelet is running on the host or in a container.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #61741 

**Special notes for your reviewer**:

Bind mounts are detected in `/proc/mounts`, but it does not contain root of mount for bind mounts. So `mount.GetMountRefsByDev()` cannot get all references if source is a normal directory. e.g.

```
# mkdir /tmp/src /mnt/dst
# mount --bind /tmp/src /tmp/src # required by local-volume-provisioner, see https://github.com/kubernetes-incubator/external-storage/pull/499
# mount --bind /tmp/src /mnt/dst
# grep -P 'src|dst' /proc/mounts 
tmpfs /tmp/src tmpfs rw,nosuid,nodev,noatime,size=4194304k 0 0
tmpfs /mnt/dst tmpfs rw,nosuid,nodev,noatime,size=4194304k 0 0
# grep -P 'src|dst' /proc/self/mountinfo 
234 409 0:42 /src /tmp/src rw,nosuid,nodev,noatime shared:30 - tmpfs tmpfs rw,size=4194304k
235 24 0:42 /src /mnt/dst rw,nosuid,nodev,noatime shared:30 - tmpfs tmpfs rw,size=4194304k
```

We need to compare root of mount and device in this case.

**Release note**:

```release-note
NONE
```
2018-05-23 19:44:24 -07:00
..
BUILD add tests for GetFileType 2018-04-10 10:53:11 +08:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
exec_mount_test.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
exec_mount_unsupported.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
exec_mount.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
exec.go Add Exec interface to VolumeHost 2017-08-14 12:16:25 +02:00
fake.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
mount_linux_test.go Fixes fsGroup check in local volume in containerized kubelet. Except 2018-05-23 10:41:42 +08:00
mount_linux.go Merge pull request #62102 from cofyc/fixlocalvolumefsgroup 2018-05-23 19:44:24 -07:00
mount_unsupported.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
mount_windows_test.go add IsLikelyNotMountPoint test on Windows 2018-05-09 02:41:38 +00:00
mount_windows.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
mount.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
nsenter_mount_test.go Lock subPath volumes 2018-03-05 09:14:44 +01:00
nsenter_mount_unsupported.go Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
nsenter_mount.go Fixes fsGroup check in local volume in containerized kubelet. Except 2018-05-23 10:41:42 +08:00
OWNERS add andyzhangx as Reviewer 2018-04-16 07:13:15 +00:00
safe_format_and_mount_test.go When creating ext3/ext4 volume, pass -m0 to mkfs in order to disable the 2018-05-21 12:43:57 -04:00