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
f8a69f10
Commit
f8a69f10
authored
Oct 12, 2018
by
Deep Debroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broaden scope of host path types to skip processing in Windows
Signed-off-by:
Deep Debroy
<
ddebroy@docker.com
>
parent
b4bb5dd4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
17 deletions
+35
-17
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+5
-4
util.go
pkg/volume/util/util.go
+9
-2
util_test.go
pkg/volume/util/util_test.go
+21
-11
No files found.
pkg/kubelet/kubelet_pods.go
View file @
f8a69f10
...
@@ -215,15 +215,16 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
...
@@ -215,15 +215,16 @@ 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:/
nor a named pipe starting with \\.\pipe\
// Docker Volume Mounts fail on Windows if it is not of the form C:/
containerPath
:=
mount
.
MountPath
containerPath
:=
mount
.
MountPath
if
runtime
.
GOOS
==
"windows"
{
if
runtime
.
GOOS
==
"windows"
{
if
!
volumeutil
.
IsWindowsNamedPipe
(
runtime
.
GOOS
,
hostPath
)
&&
(
strings
.
HasPrefix
(
hostPath
,
"/"
)
||
strings
.
HasPrefix
(
hostPath
,
"
\\
"
))
&&
!
strings
.
Contains
(
hostPath
,
":"
)
{
// Append C: only if it looks like a local path. Do not process UNC path/SMB shares/named pipes
if
(
strings
.
HasPrefix
(
hostPath
,
"/"
)
||
strings
.
HasPrefix
(
hostPath
,
"
\\
"
))
&&
!
strings
.
Contains
(
hostPath
,
":"
)
&&
!
volumeutil
.
IsWindowsUNCPath
(
runtime
.
GOOS
,
hostPath
)
{
hostPath
=
"c:"
+
hostPath
hostPath
=
"c:"
+
hostPath
}
}
}
}
// IsAbs returns false for
named pipes (\\.\pipe\...) in Windows. So check for it
specifically and skip MakeAbsolutePath
// IsAbs returns false for
UNC path/SMB shares/named pipes in Windows. So check for those
specifically and skip MakeAbsolutePath
if
!
volumeutil
.
IsWindows
NamedPipe
(
runtime
.
GOOS
,
containerPath
)
&&
!
filepath
.
IsAbs
(
containerPath
)
{
if
!
volumeutil
.
IsWindows
UNCPath
(
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 @
f8a69f10
...
@@ -945,8 +945,15 @@ func CheckPersistentVolumeClaimModeBlock(pvc *v1.PersistentVolumeClaim) bool {
...
@@ -945,8 +945,15 @@ 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
{
// IsWindowsUNCPath checks if path is prefixed with \\
if
goos
==
"windows"
&&
strings
.
HasPrefix
(
path
,
`\\.\pipe\`
)
{
// This can be used to skip any processing of paths
// that point to SMB shares, local named pipes and local UNC path
func
IsWindowsUNCPath
(
goos
,
path
string
)
bool
{
if
goos
!=
"windows"
{
return
false
}
// Check for UNC prefix \\
if
strings
.
HasPrefix
(
path
,
`\\`
)
{
return
true
return
true
}
}
return
false
return
false
...
...
pkg/volume/util/util_test.go
View file @
f8a69f10
...
@@ -2373,43 +2373,53 @@ func TestGetWindowsPath(t *testing.T) {
...
@@ -2373,43 +2373,53 @@ func TestGetWindowsPath(t *testing.T) {
}
}
}
}
func
TestIsWindows
NamedPipe
(
t
*
testing
.
T
)
{
func
TestIsWindows
UNCPath
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
goos
string
goos
string
path
string
path
string
is
NamedPipe
bool
is
UNCPath
bool
}{
}{
{
{
goos
:
"linux"
,
goos
:
"linux"
,
path
:
`/usr/bin`
,
path
:
`/usr/bin`
,
is
NamedPipe
:
false
,
is
UNCPath
:
false
,
},
},
{
{
goos
:
"linux"
,
goos
:
"linux"
,
path
:
`\\.\pipe\foo`
,
path
:
`\\.\pipe\foo`
,
is
NamedPipe
:
false
,
is
UNCPath
:
false
,
},
},
{
{
goos
:
"windows"
,
goos
:
"windows"
,
path
:
`C:\foo`
,
path
:
`C:\foo`
,
is
NamedPipe
:
false
,
is
UNCPath
:
false
,
},
},
{
{
goos
:
"windows"
,
goos
:
"windows"
,
path
:
`\\.\invalid`
,
path
:
`\\server\share\foo`
,
isNamedPipe
:
false
,
isUNCPath
:
true
,
},
{
goos
:
"windows"
,
path
:
`\\?\server\share`
,
isUNCPath
:
true
,
},
{
goos
:
"windows"
,
path
:
`\\?\c:\`
,
isUNCPath
:
true
,
},
},
{
{
goos
:
"windows"
,
goos
:
"windows"
,
path
:
`\\.\pipe\valid_pipe`
,
path
:
`\\.\pipe\valid_pipe`
,
is
NamedPipe
:
true
,
is
UNCPath
:
true
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
result
:=
IsWindows
NamedPipe
(
test
.
goos
,
test
.
path
)
result
:=
IsWindows
UNCPath
(
test
.
goos
,
test
.
path
)
if
result
!=
test
.
is
NamedPipe
{
if
result
!=
test
.
is
UNCPath
{
t
.
Errorf
(
"IsWindows
NamedPipe(%v) returned (%v), expected (%v)"
,
test
.
path
,
result
,
test
.
isNamedPipe
)
t
.
Errorf
(
"IsWindows
UNCPath(%v) returned (%v), expected (%v)"
,
test
.
path
,
result
,
test
.
isUNCPath
)
}
}
}
}
}
}
...
...
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