k3s/pkg/util
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
..
async Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
bandwidth Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
config Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
configz set right Content-Type for configz 2018-03-29 16:07:47 +08:00
conntrack Auto-updated BUILD files 2018-02-27 11:18:11 -08:00
dbus Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
ebtables Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
env Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
file Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
filesystem unpack dynamic kubelet config payloads to files 2018-04-19 09:18:53 -07:00
flag Log the command line flags 2018-02-15 18:04:04 -05:00
flock Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
goroutinemap Merge pull request #59714 from hzxuzhonghu/clean-up-goroutinemap 2018-02-27 12:05:40 -08:00
hash Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
initsystem kubeadm: Write kubelet config file to disk and persist in-cluster. Also write runtime environment file and fixup the kubelet phases command 2018-05-22 09:12:25 +03:00
interrupt
io Support nsenter in non-systemd environments 2018-04-22 22:10:36 -04:00
ipconfig Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
ipset Add comments for ipset entries in kube-proxy 2018-05-11 17:11:34 +08:00
iptables iptables: add timeout when checking rules 2018-05-02 16:25:17 +08:00
ipvs auto generated file 2018-05-22 11:20:47 +08:00
keymutex Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
labels Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
limitwriter Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
maps
metrics Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
mount Merge pull request #62102 from cofyc/fixlocalvolumefsgroup 2018-05-23 19:44:24 -07:00
net Auto-updated BUILD files 2018-02-27 11:18:11 -08:00
netsh Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
node Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
normalizer Clone documentation utility from //pkg/kubectl/cmd/templates 2017-11-16 10:18:00 +01:00
nsenter Merge pull request #62903 from cofyc/fixfsgroupcheckinlocal 2018-05-02 20:13:11 -07:00
oom Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
parsers Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
pointer pkg/util/pointer: Update `int` pointer functions 2018-03-27 10:30:01 -04:00
procfs Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
reflector/prometheus rename metric reflector_xx_last_resource_version to reflector_last_resource_version{name="xx"} 2017-11-01 16:34:18 +08:00
removeall Add GetSELinuxSupport to mounter. 2018-05-17 13:36:37 +02:00
resizefs Perform resize of mounted volume if necessary 2018-01-29 17:49:50 -05:00
resourcecontainer Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
rlimit Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
selinux Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
slice Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
strings Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
sysctl
system Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
tail Merge pull request #59713 from hanxiaoshuai/fix0211 2018-02-22 23:17:38 -08:00
taints Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
template Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
term Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
threading Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
tolerations Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
version Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
workqueue/prometheus
BUILD Remove conntrack entry on udp rule add. 2018-02-22 23:34:42 -08:00
verify-util-pkg.sh Update all script to use /usr/bin/env bash in shebang 2018-04-19 13:20:13 +02:00