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
74f01026
Commit
74f01026
authored
Sep 13, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix UnmountDevice failure on Windows
add comments fix test failure
parent
76518f15
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
26 deletions
+18
-26
mount_windows.go
pkg/util/mount/mount_windows.go
+2
-5
mount_windows_test.go
pkg/util/mount/mount_windows_test.go
+16
-21
No files found.
pkg/util/mount/mount_windows.go
View file @
74f01026
...
@@ -458,17 +458,14 @@ func getAllParentLinks(path string) ([]string, error) {
...
@@ -458,17 +458,14 @@ func getAllParentLinks(path string) ([]string, error) {
return
links
,
nil
return
links
,
nil
}
}
// GetMountRefs : empty implementation here since there is no place to query all mount points on Windows
func
(
mounter
*
Mounter
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
func
(
mounter
*
Mounter
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
if
_
,
err
:=
os
.
Stat
(
normalizeWindowsPath
(
pathname
));
os
.
IsNotExist
(
err
)
{
if
_
,
err
:=
os
.
Stat
(
normalizeWindowsPath
(
pathname
));
os
.
IsNotExist
(
err
)
{
return
[]
string
{},
nil
return
[]
string
{},
nil
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
refs
,
err
:=
getAllParentLinks
(
normalizeWindowsPath
(
pathname
))
return
[]
string
{
pathname
},
nil
if
err
!=
nil
{
return
nil
,
err
}
return
refs
,
nil
}
}
// Note that on windows, it always returns 0. We actually don't set FSGroup on
// Note that on windows, it always returns 0. We actually don't set FSGroup on
...
...
pkg/util/mount/mount_windows_test.go
View file @
74f01026
...
@@ -111,30 +111,25 @@ func setEquivalent(set1, set2 []string) bool {
...
@@ -111,30 +111,25 @@ func setEquivalent(set1, set2 []string) bool {
// this func must run in admin mode, otherwise it will fail
// this func must run in admin mode, otherwise it will fail
func
TestGetMountRefs
(
t
*
testing
.
T
)
{
func
TestGetMountRefs
(
t
*
testing
.
T
)
{
fm
:=
&
FakeMounter
{
MountPoints
:
[]
MountPoint
{}}
tests
:=
[]
struct
{
mountPath
:=
`c:\secondmountpath`
mountPath
string
expectedRefs
:=
[]
string
{
`c:\`
,
`c:\firstmountpath`
,
mountPath
}
expectedRefs
[]
string
}{
// remove symbolic links first
{
for
i
:=
1
;
i
<
len
(
expectedRefs
);
i
++
{
mountPath
:
`c:\windows`
,
removeLink
(
expectedRefs
[
i
])
expectedRefs
:
[]
string
{
`c:\windows`
},
}
},
{
// create symbolic links
mountPath
:
`c:\doesnotexist`
,
for
i
:=
1
;
i
<
len
(
expectedRefs
);
i
++
{
expectedRefs
:
[]
string
{},
if
err
:=
makeLink
(
expectedRefs
[
i
],
expectedRefs
[
i
-
1
]);
err
!=
nil
{
},
t
.
Errorf
(
"makeLink failed: %v"
,
err
)
}
}
}
if
refs
,
err
:=
fm
.
GetMountRefs
(
mountPath
);
err
!=
nil
||
!
setEquivalent
(
expectedRefs
,
refs
)
{
mounter
:=
Mounter
{
"fake/path"
}
t
.
Errorf
(
"getMountRefs(%q) = %v, error: %v; expected %v"
,
mountPath
,
refs
,
err
,
expectedRefs
)
}
// remove symbolic links
for
_
,
test
:=
range
tests
{
for
i
:=
1
;
i
<
len
(
expectedRefs
);
i
++
{
if
refs
,
err
:=
mounter
.
GetMountRefs
(
test
.
mountPath
);
err
!=
nil
||
!
setEquivalent
(
test
.
expectedRefs
,
refs
)
{
if
err
:=
removeLink
(
expectedRefs
[
i
]);
err
!=
nil
{
t
.
Errorf
(
"getMountRefs(%q) = %v, error: %v; expected %v"
,
test
.
mountPath
,
refs
,
err
,
test
.
expectedRefs
)
t
.
Errorf
(
"removeLink failed: %v"
,
err
)
}
}
}
}
}
}
...
...
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