• Kubernetes Submit Queue's avatar
    Merge pull request #62102 from cofyc/fixlocalvolumefsgroup · 481b2dc7
    Kubernetes Submit Queue authored
    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
    ```
    481b2dc7
Name
Last commit
Last update
..
BUILD Loading commit data...
OWNERS Loading commit data...
doc.go Loading commit data...
exec.go Loading commit data...
exec_mount.go Loading commit data...
exec_mount_test.go Loading commit data...
exec_mount_unsupported.go Loading commit data...
fake.go Loading commit data...
mount.go Loading commit data...
mount_linux.go Loading commit data...
mount_linux_test.go Loading commit data...
mount_unsupported.go Loading commit data...
mount_windows.go Loading commit data...
mount_windows_test.go Loading commit data...
nsenter_mount.go Loading commit data...
nsenter_mount_test.go Loading commit data...
nsenter_mount_unsupported.go Loading commit data...
safe_format_and_mount_test.go Loading commit data...