Merge pull request #62018 from andyzhangx/local-windows-path-fix
Automatic merge from submit-queue (batch tested with PRs 61147, 62236, 62018). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix local volume absolute path issue on Windows **What this PR does / why we need it**: remove IsAbs validation on local volume since it does not work on windows cluster, Windows absolute path `D:` is not allowed in local volume, the [validation](https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L1386) happens on both master and agent node, while for windows cluster, the master is Linux and agent is Windows, so `path.IsAbs()` func will not work all in both nodes. **Instead**, this PR use `MakeAbsolutePath` func to convert `local.path` value in kubelet, it supports both linux and windows styple. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #62016 **Special notes for your reviewer**: **Release note**: ``` fix local volume absolute path issue on Windows ``` /sig storage /sig windows
This commit is contained in:
@@ -51,52 +51,6 @@ import (
|
||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||
)
|
||||
|
||||
func TestMakeAbsolutePath(t *testing.T) {
|
||||
tests := []struct {
|
||||
goos string
|
||||
path string
|
||||
expectedPath string
|
||||
name string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
path: "non-absolute/path",
|
||||
expectedPath: "/non-absolute/path",
|
||||
name: "basic linux",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "some\\path",
|
||||
expectedPath: "c:\\some\\path",
|
||||
name: "basic windows",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "/some/path",
|
||||
expectedPath: "c:/some/path",
|
||||
name: "linux path on windows",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "\\some\\path",
|
||||
expectedPath: "c:\\some\\path",
|
||||
name: "windows path no drive",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "\\:\\some\\path",
|
||||
expectedPath: "\\:\\some\\path",
|
||||
name: "windows path with colon",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
path := makeAbsolutePath(test.goos, test.path)
|
||||
if path != test.expectedPath {
|
||||
t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMakeMounts(t *testing.T) {
|
||||
bTrue := true
|
||||
propagationHostToContainer := v1.MountPropagationHostToContainer
|
||||
|
Reference in New Issue
Block a user