Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b4bb5dd4
Commit
b4bb5dd4
authored
Oct 05, 2018
by
Deep Debroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle named pipe host mounts for Windows
Signed-off-by:
Deep Debroy
<
ddebroy@docker.com
>
parent
2f349d58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+4
-3
util.go
pkg/volume/util/util.go
+7
-0
util_test.go
pkg/volume/util/util_test.go
+41
-0
No files found.
pkg/kubelet/kubelet_pods.go
View file @
b4bb5dd4
...
@@ -215,14 +215,15 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
...
@@ -215,14 +215,15 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
}
}
}
}
// Docker Volume Mounts fail on Windows if it is not of the form C:/
// Docker Volume Mounts fail on Windows if it is not of the form C:/
nor a named pipe starting with \\.\pipe\
containerPath
:=
mount
.
MountPath
containerPath
:=
mount
.
MountPath
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
if
(
strings
.
HasPrefix
(
hostPath
,
"/"
)
||
strings
.
HasPrefix
(
hostPath
,
"
\\
"
))
&&
!
strings
.
Contains
(
hostPath
,
":"
)
{
if
!
volumeutil
.
IsWindowsNamedPipe
(
runtime
.
GOOS
,
hostPath
)
&&
(
strings
.
HasPrefix
(
hostPath
,
"/"
)
||
strings
.
HasPrefix
(
hostPath
,
"
\\
"
))
&&
!
strings
.
Contains
(
hostPath
,
":"
)
{
hostPath
=
"c:"
+
hostPath
hostPath
=
"c:"
+
hostPath
}
}
}
}
if
!
filepath
.
IsAbs
(
containerPath
)
{
// IsAbs returns false for named pipes (\\.\pipe\...) in Windows. So check for it specifically and skip MakeAbsolutePath
if
!
volumeutil
.
IsWindowsNamedPipe
(
runtime
.
GOOS
,
containerPath
)
&&
!
filepath
.
IsAbs
(
containerPath
)
{
containerPath
=
volumeutil
.
MakeAbsolutePath
(
runtime
.
GOOS
,
containerPath
)
containerPath
=
volumeutil
.
MakeAbsolutePath
(
runtime
.
GOOS
,
containerPath
)
}
}
...
...
pkg/volume/util/util.go
View file @
b4bb5dd4
...
@@ -945,6 +945,13 @@ func CheckPersistentVolumeClaimModeBlock(pvc *v1.PersistentVolumeClaim) bool {
...
@@ -945,6 +945,13 @@ func CheckPersistentVolumeClaimModeBlock(pvc *v1.PersistentVolumeClaim) bool {
return
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
&&
pvc
.
Spec
.
VolumeMode
!=
nil
&&
*
pvc
.
Spec
.
VolumeMode
==
v1
.
PersistentVolumeBlock
return
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
&&
pvc
.
Spec
.
VolumeMode
!=
nil
&&
*
pvc
.
Spec
.
VolumeMode
==
v1
.
PersistentVolumeBlock
}
}
func
IsWindowsNamedPipe
(
goos
,
path
string
)
bool
{
if
goos
==
"windows"
&&
strings
.
HasPrefix
(
path
,
`\\.\pipe\`
)
{
return
true
}
return
false
}
// MakeAbsolutePath convert path to absolute path according to GOOS
// MakeAbsolutePath convert path to absolute path according to GOOS
func
MakeAbsolutePath
(
goos
,
path
string
)
string
{
func
MakeAbsolutePath
(
goos
,
path
string
)
string
{
if
goos
!=
"windows"
{
if
goos
!=
"windows"
{
...
...
pkg/volume/util/util_test.go
View file @
b4bb5dd4
...
@@ -2373,6 +2373,47 @@ func TestGetWindowsPath(t *testing.T) {
...
@@ -2373,6 +2373,47 @@ func TestGetWindowsPath(t *testing.T) {
}
}
}
}
func
TestIsWindowsNamedPipe
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
goos
string
path
string
isNamedPipe
bool
}{
{
goos
:
"linux"
,
path
:
`/usr/bin`
,
isNamedPipe
:
false
,
},
{
goos
:
"linux"
,
path
:
`\\.\pipe\foo`
,
isNamedPipe
:
false
,
},
{
goos
:
"windows"
,
path
:
`C:\foo`
,
isNamedPipe
:
false
,
},
{
goos
:
"windows"
,
path
:
`\\.\invalid`
,
isNamedPipe
:
false
,
},
{
goos
:
"windows"
,
path
:
`\\.\pipe\valid_pipe`
,
isNamedPipe
:
true
,
},
}
for
_
,
test
:=
range
tests
{
result
:=
IsWindowsNamedPipe
(
test
.
goos
,
test
.
path
)
if
result
!=
test
.
isNamedPipe
{
t
.
Errorf
(
"IsWindowsNamedPipe(%v) returned (%v), expected (%v)"
,
test
.
path
,
result
,
test
.
isNamedPipe
)
}
}
}
func
TestMakeAbsolutePath
(
t
*
testing
.
T
)
{
func
TestMakeAbsolutePath
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
goos
string
goos
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment