mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
kubeadm: fix invalid cross-device link
error
The root cause for that error is because `rename` doesn't work across different mount points. The kubelet config file and back up directory are mounted to different file system in kinder environment. ``` df /var/lib/kubelet/config.yaml | tail -n1 | awk '{print $1}' /dev/sda2 df /etc/kubernetes/tmp/kubeadm-kubelet-configxxx | tail -n1 | awk '{print $1}' overlay ``` Call `cp` instead of `rename` to back up the kubelet file would fix that issue. Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
016cc0c120
commit
c55a98fde9
@ -29,6 +29,7 @@ import (
|
|||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
|
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade"
|
"k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade"
|
||||||
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
dryrunutil "k8s.io/kubernetes/cmd/kubeadm/app/util/dryrun"
|
dryrunutil "k8s.io/kubernetes/cmd/kubeadm/app/util/dryrun"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,8 +81,13 @@ func runKubeletConfigPhase() func(c workflow.RunData) error {
|
|||||||
dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName)
|
dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName)
|
||||||
if !dryRun {
|
if !dryRun {
|
||||||
fmt.Printf("[upgrade] Backing up kubelet config file to %s\n", dest)
|
fmt.Printf("[upgrade] Backing up kubelet config file to %s\n", dest)
|
||||||
if err := os.Rename(src, dest); err != nil {
|
// call `cp` instead of `rename` here since the kubelet config file and back up directory (/etc/kubernetes/tmp/)
|
||||||
return errors.Wrap(err, "error backing up the kubelet config file")
|
// might on the filesystem with differnt mount points in the test environment, such as kinder.
|
||||||
|
// This will lead to a failure to move the file from the source to dest since `rename` normally doesn't work
|
||||||
|
// across different mount points on most Unix system.
|
||||||
|
output, err := kubeadmutil.CopyDir(src, dest)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "error backing up the kubelet config file, output: %q", output)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("[dryrun] Would back up kubelet config file to %s\n", dest)
|
fmt.Printf("[dryrun] Would back up kubelet config file to %s\n", dest)
|
||||||
|
Loading…
Reference in New Issue
Block a user