• Kubernetes Submit Queue's avatar
    Merge pull request #43378 from jsafrane/fix-partition-mount · 1ed77078
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 43378, 43216, 43384, 43083, 43428)
    
    Do not reformat devices with partitions
    
    `lsblk` reports FSTYPE of devices with partition tables as empty string `""`,
    which is indistinguishable from empty devices. We must look for dependent
    devices (i.e. partitions) to see that the device is really empty and report
    error otherwise.
    
    The main point of this patch is to run `lsblk` without `"-n"`, i.e. print all
    dependent devices and check it output.
    
    Sample output:
    ```
      FirstSeen     LastSeen        Count   From                                    SubObjectPath   Type            Reason          Message
      ---------     --------        -----   ----                                    -------------   --------        ------          -------
      10s           10s             1       default-scheduler                                       Normal          Scheduled       Successfully assigned testpod to ip-172-18-11-149.ec2.internal
      2s            2s              1       kubelet, ip-172-18-11-149.ec2.internal                  Warning         FailedMount     MountVolume.MountDevice failed for volume "kubernetes.io/aws-ebs/vol-0fa9da8b91913b187" (spec.Name: "vol") pod "b74f68c5-0d6a-11e7-9233-0e11251010c0" (UID: "b74f68c5-0d6a-11e7-9233-0e11251010c0") with: failed to mount the volume as "ext4", it already contains unknown data, probably partitions. Mount error: mount failed: exit status 32
    Mounting command: mount
    Mounting arguments: /dev/xvdbb /var/lib/kubelet/plugins/kubernetes.io/aws-ebs/mounts/vol-0fa9da8b91913b187 ext4 [defaults]
    Output: mount: wrong fs type, bad option, bad superblock on /dev/xvdbb,
           missing codepage or helper program, or other error
    
           In some cases useful info is found in syslog - try
           dmesg | tail or so.
    
    ```
    
    Without this patch, the device would be reformatted and all data in the device partitions would be lost.
    
    Fixes #13212
    
    Release note:
    ```release-note
    NONE
    ```
    
    @kubernetes/sig-storage-pr-reviews
    1ed77078
Name
Last commit
Last update
..
async Loading commit data...
bandwidth Loading commit data...
chmod Loading commit data...
chown Loading commit data...
config Loading commit data...
configz Loading commit data...
crlf Loading commit data...
dbus Loading commit data...
ebtables Loading commit data...
env Loading commit data...
errors Loading commit data...
exec Loading commit data...
flock Loading commit data...
framer Loading commit data...
goroutinemap Loading commit data...
hash Loading commit data...
i18n Loading commit data...
initsystem Loading commit data...
interrupt Loading commit data...
intstr Loading commit data...
io Loading commit data...
ipconfig Loading commit data...
iptables Loading commit data...
json Loading commit data...
keymutex Loading commit data...
labels Loading commit data...
limitwriter Loading commit data...
logs Loading commit data...
maps Loading commit data...
metrics Loading commit data...
mount Loading commit data...
net Loading commit data...
netsh Loading commit data...
node Loading commit data...
oom Loading commit data...
parsers Loading commit data...
procfs Loading commit data...
rand Loading commit data...
removeall Loading commit data...
resourcecontainer Loading commit data...
rlimit Loading commit data...
runtime Loading commit data...
selinux Loading commit data...
sets Loading commit data...
slice Loading commit data...
strings Loading commit data...
sysctl Loading commit data...
system Loading commit data...
tail Loading commit data...
taints Loading commit data...
term Loading commit data...
threading Loading commit data...
uuid Loading commit data...
validation Loading commit data...
version Loading commit data...
wait Loading commit data...
workqueue/prometheus Loading commit data...
yaml Loading commit data...
BUILD Loading commit data...
doc.go Loading commit data...
template.go Loading commit data...
template_test.go Loading commit data...
umask.go Loading commit data...
umask_windows.go Loading commit data...
util.go Loading commit data...
util_test.go Loading commit data...