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
c718fc2c
Commit
c718fc2c
authored
Oct 27, 2017
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't cache exec and mounter in RBD volume plugin
Volume plugin can get a different exec and mounter implementation with every call, it must not be cached.
parent
d9459270
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
13 deletions
+15
-13
attacher.go
pkg/volume/rbd/attacher.go
+9
-4
rbd.go
pkg/volume/rbd/rbd.go
+4
-8
rbd_util.go
pkg/volume/rbd/rbd_util.go
+2
-1
No files found.
pkg/volume/rbd/attacher.go
View file @
c718fc2c
...
...
@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// NewAttacher implements AttachableVolumePlugin.NewAttacher.
...
...
@@ -38,6 +39,7 @@ func (plugin *rbdPlugin) newAttacherInternal(manager diskManager) (volume.Attach
return
&
rbdAttacher
{
plugin
:
plugin
,
manager
:
manager
,
mounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
},
nil
}
...
...
@@ -50,6 +52,7 @@ func (plugin *rbdPlugin) newDetacherInternal(manager diskManager) (volume.Detach
return
&
rbdDetacher
{
plugin
:
plugin
,
manager
:
manager
,
mounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
},
nil
}
...
...
@@ -62,6 +65,7 @@ func (plugin *rbdPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, e
// rbdAttacher implements volume.Attacher interface.
type
rbdAttacher
struct
{
plugin
*
rbdPlugin
mounter
*
mount
.
SafeFormatAndMount
manager
diskManager
}
...
...
@@ -124,7 +128,7 @@ func (attacher *rbdAttacher) GetDeviceMountPath(spec *volume.Spec) (string, erro
// This method is idempotent, callers are responsible for retrying on failure.
func
(
attacher
*
rbdAttacher
)
MountDevice
(
spec
*
volume
.
Spec
,
devicePath
string
,
deviceMountPath
string
)
error
{
glog
.
V
(
4
)
.
Infof
(
"rbd: mouting device %s to %s"
,
devicePath
,
deviceMountPath
)
notMnt
,
err
:=
attacher
.
plugin
.
mounter
.
IsLikelyNotMountPoint
(
deviceMountPath
)
notMnt
,
err
:=
attacher
.
mounter
.
IsLikelyNotMountPoint
(
deviceMountPath
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
deviceMountPath
,
0750
);
err
!=
nil
{
...
...
@@ -151,7 +155,7 @@ func (attacher *rbdAttacher) MountDevice(spec *volume.Spec, devicePath string, d
options
=
append
(
options
,
"ro"
)
}
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
attacher
.
plugin
.
mounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
fstype
,
mountOptions
)
err
=
attacher
.
mounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
fstype
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
return
fmt
.
Errorf
(
"rbd: failed to mount device %s at %s (fstype: %s), error %v"
,
devicePath
,
deviceMountPath
,
fstype
,
err
)
...
...
@@ -164,6 +168,7 @@ func (attacher *rbdAttacher) MountDevice(spec *volume.Spec, devicePath string, d
type
rbdDetacher
struct
{
plugin
*
rbdPlugin
manager
diskManager
mounter
*
mount
.
SafeFormatAndMount
}
var
_
volume
.
Detacher
=
&
rbdDetacher
{}
...
...
@@ -185,7 +190,7 @@ func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
glog
.
Warningf
(
"Warning: Unmount skipped because path does not exist: %v"
,
deviceMountPath
)
return
nil
}
devicePath
,
cnt
,
err
:=
mount
.
GetDeviceNameFromMount
(
detacher
.
plugin
.
mounter
,
deviceMountPath
)
devicePath
,
cnt
,
err
:=
mount
.
GetDeviceNameFromMount
(
detacher
.
mounter
,
deviceMountPath
)
if
err
!=
nil
{
return
err
}
...
...
@@ -195,7 +200,7 @@ func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
if
cnt
==
1
{
// Unmount the device from the device mount point.
glog
.
V
(
4
)
.
Infof
(
"rbd: unmouting device mountpoint %s"
,
deviceMountPath
)
if
err
=
detacher
.
plugin
.
mounter
.
Unmount
(
deviceMountPath
);
err
!=
nil
{
if
err
=
detacher
.
mounter
.
Unmount
(
deviceMountPath
);
err
!=
nil
{
return
err
}
glog
.
V
(
3
)
.
Infof
(
"rbd: successfully umount device mountpath %s"
,
deviceMountPath
)
...
...
pkg/volume/rbd/rbd.go
View file @
c718fc2c
...
...
@@ -41,14 +41,12 @@ var (
// This is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
rbdPlugin
{
nil
,
nil
,
nil
}}
return
[]
volume
.
VolumePlugin
{
&
rbdPlugin
{}}
}
// rbdPlugin implements Volume.VolumePlugin.
type
rbdPlugin
struct
{
host
volume
.
VolumeHost
exec
mount
.
Exec
mounter
*
mount
.
SafeFormatAndMount
host
volume
.
VolumeHost
}
var
_
volume
.
VolumePlugin
=
&
rbdPlugin
{}
...
...
@@ -74,8 +72,6 @@ func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
func
(
plugin
*
rbdPlugin
)
Init
(
host
volume
.
VolumeHost
)
error
{
plugin
.
host
=
host
plugin
.
exec
=
host
.
GetExec
(
plugin
.
GetPluginName
())
plugin
.
mounter
=
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)
return
nil
}
...
...
@@ -505,8 +501,8 @@ func newRBD(podUID types.UID, volName string, image string, pool string, readOnl
Pool
:
pool
,
ReadOnly
:
readOnly
,
plugin
:
plugin
,
mounter
:
plugin
.
mounter
,
exec
:
plugin
.
exec
,
mounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)
,
exec
:
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
())
,
manager
:
manager
,
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
volName
,
plugin
.
host
)),
}
...
...
pkg/volume/rbd/rbd_util.go
View file @
c718fc2c
...
...
@@ -297,7 +297,8 @@ func (util *RBDUtil) DetachDisk(plugin *rbdPlugin, deviceMountPath string, devic
var
err
error
if
len
(
device
)
>
0
{
// rbd unmap
_
,
err
=
plugin
.
exec
.
Run
(
"rbd"
,
"unmap"
,
device
)
exec
:=
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
())
_
,
err
=
exec
.
Run
(
"rbd"
,
"unmap"
,
device
)
if
err
!=
nil
{
return
rbdErrors
(
err
,
fmt
.
Errorf
(
"rbd: failed to unmap device %s:Error: %v"
,
device
,
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