mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
fixing issue where SMB share paths cannot resolve with CRI-containerD on Windows
This commit is contained in:
parent
082146a6e6
commit
b14e83333b
@ -132,12 +132,23 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := exec.Command("cmd", "/c", "mklink", "/D", target, bindSource).CombinedOutput()
|
// There is an issue in golang where EvalSymlinks fails on Windows when passed a
|
||||||
|
// UNC share root path without a trailing backslash.
|
||||||
|
// Ex: \\SERVER\share will fail to resolve but \\SERVER\share\ will resolve
|
||||||
|
// containerD on Windows calls EvalSymlinks so we'll add the backslash when making the symlink if it is missing.
|
||||||
|
// https://github.com/golang/go/pull/42096 fixes this issue in golang but a fix will not be available until
|
||||||
|
// golang v1.16
|
||||||
|
mklinkSource := bindSource
|
||||||
|
if !strings.HasSuffix(mklinkSource, "\\") {
|
||||||
|
mklinkSource = mklinkSource + "\\"
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := exec.Command("cmd", "/c", "mklink", "/D", target, mklinkSource).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, bindSource, target, string(output))
|
klog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, mklinkSource, target, string(output))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
klog.V(2).Infof("mklink source(%q) on target(%q) successfully, output: %q", bindSource, target, string(output))
|
klog.V(2).Infof("mklink source(%q) on target(%q) successfully, output: %q", mklinkSource, target, string(output))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user