mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
Merge pull request #122619 from neolit123/1.30-v1beta4-control-reset-unmount
kubeadm: skip unmount on missing /var/lib/kubelet
This commit is contained in:
commit
18608cc56b
@ -81,18 +81,21 @@ func runCleanupNode(c workflow.RunData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !r.DryRun() {
|
if !r.DryRun() {
|
||||||
// Try to unmount mounted directories under kubeadmconstants.KubeletRunDirectory in order to be able to remove the kubeadmconstants.KubeletRunDirectory directory later
|
// In case KubeletRunDirectory holds a symbolic link, evaluate it.
|
||||||
fmt.Printf("[reset] Unmounting mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory)
|
// This would also throw an error if the directory does not exist.
|
||||||
// In case KubeletRunDirectory holds a symbolic link, evaluate it
|
kubeletRunDirectory, err := filepath.EvalSymlinks(kubeadmconstants.KubeletRunDirectory)
|
||||||
kubeletRunDirectory, err := absoluteKubeletRunDirectory()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
klog.Warningf("[reset] Skipping unmount of directories in %q: %v\n",
|
||||||
|
kubeadmconstants.KubeletRunDirectory, err)
|
||||||
|
} else {
|
||||||
|
// Unmount all mount paths under kubeletRunDirectory.
|
||||||
|
fmt.Printf("[reset] Unmounting mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory)
|
||||||
|
if err := unmountKubeletDirectory(kubeletRunDirectory, r.ResetCfg().UnmountFlags); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Clean the kubeletRunDirectory.
|
||||||
|
dirsToClean = append(dirsToClean, kubeletRunDirectory)
|
||||||
}
|
}
|
||||||
// Unmount all mount paths under kubeletRunDirectory
|
|
||||||
if err := unmountKubeletDirectory(kubeletRunDirectory, r.ResetCfg().UnmountFlags); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
dirsToClean = append(dirsToClean, kubeletRunDirectory)
|
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("[reset] Would unmount mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory)
|
fmt.Printf("[reset] Would unmount mounted directories in %q\n", kubeadmconstants.KubeletRunDirectory)
|
||||||
}
|
}
|
||||||
@ -132,14 +135,6 @@ func runCleanupNode(c workflow.RunData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func absoluteKubeletRunDirectory() (string, error) {
|
|
||||||
absoluteKubeletRunDirectory, err := filepath.EvalSymlinks(kubeadmconstants.KubeletRunDirectory)
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.Wrapf(err, "failed to evaluate the %q directory", kubeadmconstants.KubeletRunDirectory)
|
|
||||||
}
|
|
||||||
return absoluteKubeletRunDirectory, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeContainers(execer utilsexec.Interface, criSocketPath string) error {
|
func removeContainers(execer utilsexec.Interface, criSocketPath string) error {
|
||||||
containerRuntime, err := utilruntime.NewContainerRuntime(execer, criSocketPath)
|
containerRuntime, err := utilruntime.NewContainerRuntime(execer, criSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user