Commit 48a961cf authored by Ed Bartosh's avatar Ed Bartosh

kubeadm: properly umount dirs in /var/lib/kubelet

'kubeadm reset' uses incorrect way of unmounting /var/lib/kubelet directories. It queries /proc/mounts for /var/lib/kubelet mount point. If /var/lib/kubelet directory is also mounted it makes 'kubelet reset' to unmount it too, which is incorrect. It also makes it fail as it can't unmount /var/lib/kubelet before unmounting mounts inside it. Fixed by querying /var/lib/kubelet/ instead of /var/lib/kubelet. This should exclude /var/lib/kubelet from the query results even if it's mounted. Fixes: kubernetes/kubeadm#1294
parent dc9261bc
...@@ -156,7 +156,7 @@ func (r *Reset) Run(out io.Writer, client clientset.Interface) error { ...@@ -156,7 +156,7 @@ func (r *Reset) Run(out io.Writer, client clientset.Interface) error {
// Try to unmount mounted directories under kubeadmconstants.KubeletRunDirectory in order to be able to remove the kubeadmconstants.KubeletRunDirectory directory later // Try to unmount mounted directories under kubeadmconstants.KubeletRunDirectory in order to be able to remove the kubeadmconstants.KubeletRunDirectory directory later
fmt.Printf("[reset] unmounting mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory) fmt.Printf("[reset] unmounting mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory)
umountDirsCmd := fmt.Sprintf("awk '$2 ~ path {print $2}' path=%s /proc/mounts | xargs -r umount", kubeadmconstants.KubeletRunDirectory) umountDirsCmd := fmt.Sprintf("awk '$2 ~ path {print $2}' path=%s/ /proc/mounts | xargs -r umount", kubeadmconstants.KubeletRunDirectory)
klog.V(1).Infof("[reset] executing command %q", umountDirsCmd) klog.V(1).Infof("[reset] executing command %q", umountDirsCmd)
umountOutputBytes, err := exec.Command("sh", "-c", umountDirsCmd).Output() umountOutputBytes, err := exec.Command("sh", "-c", umountDirsCmd).Output()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment