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
4b4b6cdc
Commit
4b4b6cdc
authored
Mar 14, 2019
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix race condition issue for smb mount on windows
change var name
parent
897d62ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
BUILD
pkg/util/mount/BUILD
+1
-0
mount_windows.go
pkg/util/mount/mount_windows.go
+8
-0
No files found.
pkg/util/mount/BUILD
View file @
4b4b6cdc
...
@@ -59,6 +59,7 @@ go_library(
...
@@ -59,6 +59,7 @@ go_library(
"//vendor/k8s.io/utils/nsenter:go_default_library",
"//vendor/k8s.io/utils/nsenter:go_default_library",
],
],
"@io_bazel_rules_go//go/platform:windows": [
"@io_bazel_rules_go//go/platform:windows": [
"//vendor/k8s.io/utils/keymutex:go_default_library",
"//vendor/k8s.io/utils/nsenter:go_default_library",
"//vendor/k8s.io/utils/nsenter:go_default_library",
"//vendor/k8s.io/utils/path:go_default_library",
"//vendor/k8s.io/utils/path:go_default_library",
],
],
...
...
pkg/util/mount/mount_windows.go
View file @
4b4b6cdc
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"strings"
"strings"
"k8s.io/klog"
"k8s.io/klog"
"k8s.io/utils/keymutex"
utilpath
"k8s.io/utils/path"
utilpath
"k8s.io/utils/path"
)
)
...
@@ -48,6 +49,9 @@ func New(mounterPath string) Interface {
...
@@ -48,6 +49,9 @@ func New(mounterPath string) Interface {
}
}
}
}
// acquire lock for smb mount
var
getSMBMountMutex
=
keymutex
.
NewHashed
(
0
)
// Mount : mounts source to target with given options.
// Mount : mounts source to target with given options.
// currently only supports cifs(smb), bind mount(for disk)
// currently only supports cifs(smb), bind mount(for disk)
func
(
mounter
*
Mounter
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
func
(
mounter
*
Mounter
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
...
@@ -83,6 +87,10 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
...
@@ -83,6 +87,10 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
return
fmt
.
Errorf
(
"only cifs mount is supported now, fstype: %q, mounting source (%q), target (%q), with options (%q)"
,
fstype
,
source
,
target
,
options
)
return
fmt
.
Errorf
(
"only cifs mount is supported now, fstype: %q, mounting source (%q), target (%q), with options (%q)"
,
fstype
,
source
,
target
,
options
)
}
}
// lock smb mount for the same source
getSMBMountMutex
.
LockKey
(
source
)
defer
getSMBMountMutex
.
UnlockKey
(
source
)
if
output
,
err
:=
newSMBMapping
(
options
[
0
],
options
[
1
],
source
);
err
!=
nil
{
if
output
,
err
:=
newSMBMapping
(
options
[
0
],
options
[
1
],
source
);
err
!=
nil
{
if
isSMBMappingExist
(
source
)
{
if
isSMBMappingExist
(
source
)
{
klog
.
V
(
2
)
.
Infof
(
"SMB Mapping(%s) already exists, now begin to remove and remount"
,
source
)
klog
.
V
(
2
)
.
Infof
(
"SMB Mapping(%s) already exists, now begin to remove and remount"
,
source
)
...
...
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