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
fe6399a6
Commit
fe6399a6
authored
Jun 29, 2015
by
markturansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed plugin name from exported to private
parent
70644b68
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
rbd.go
pkg/volume/rbd/rbd.go
+17
-17
rbd_test.go
pkg/volume/rbd/rbd_test.go
+2
-2
rbd_util.go
pkg/volume/rbd/rbd_util.go
+1
-1
No files found.
pkg/volume/rbd/rbd.go
View file @
fe6399a6
...
...
@@ -30,29 +30,29 @@ import (
// This is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
RBD
Plugin
{
nil
,
exec
.
New
()}}
return
[]
volume
.
VolumePlugin
{
&
rbd
Plugin
{
nil
,
exec
.
New
()}}
}
type
RBD
Plugin
struct
{
type
rbd
Plugin
struct
{
host
volume
.
VolumeHost
exe
exec
.
Interface
}
var
_
volume
.
VolumePlugin
=
&
RBD
Plugin
{}
var
_
volume
.
VolumePlugin
=
&
rbd
Plugin
{}
const
(
RBD
PluginName
=
"kubernetes.io/rbd"
rbd
PluginName
=
"kubernetes.io/rbd"
)
func
(
plugin
*
RBD
Plugin
)
Init
(
host
volume
.
VolumeHost
)
{
func
(
plugin
*
rbd
Plugin
)
Init
(
host
volume
.
VolumeHost
)
{
plugin
.
host
=
host
}
func
(
plugin
*
RBD
Plugin
)
Name
()
string
{
return
RBD
PluginName
func
(
plugin
*
rbd
Plugin
)
Name
()
string
{
return
rbd
PluginName
}
func
(
plugin
*
RBD
Plugin
)
CanSupport
(
spec
*
volume
.
Spec
)
bool
{
func
(
plugin
*
rbd
Plugin
)
CanSupport
(
spec
*
volume
.
Spec
)
bool
{
if
spec
.
VolumeSource
.
RBD
==
nil
&&
spec
.
PersistentVolumeSource
.
RBD
==
nil
{
return
false
}
...
...
@@ -65,14 +65,14 @@ func (plugin *RBDPlugin) CanSupport(spec *volume.Spec) bool {
return
false
}
func
(
plugin
*
RBD
Plugin
)
GetAccessModes
()
[]
api
.
PersistentVolumeAccessMode
{
func
(
plugin
*
rbd
Plugin
)
GetAccessModes
()
[]
api
.
PersistentVolumeAccessMode
{
return
[]
api
.
PersistentVolumeAccessMode
{
api
.
ReadWriteOnce
,
api
.
ReadOnlyMany
,
}
}
func
(
plugin
*
RBD
Plugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
rbd
Plugin
)
NewBuilder
(
spec
*
volume
.
Spec
,
pod
*
api
.
Pod
,
_
volume
.
VolumeOptions
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
secret
:=
""
source
:=
plugin
.
getRBDVolumeSource
(
spec
)
...
...
@@ -97,7 +97,7 @@ func (plugin *RBDPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.Vo
return
plugin
.
newBuilderInternal
(
spec
,
pod
.
UID
,
&
RBDUtil
{},
mounter
,
secret
)
}
func
(
plugin
*
RBD
Plugin
)
getRBDVolumeSource
(
spec
*
volume
.
Spec
)
*
api
.
RBDVolumeSource
{
func
(
plugin
*
rbd
Plugin
)
getRBDVolumeSource
(
spec
*
volume
.
Spec
)
*
api
.
RBDVolumeSource
{
if
spec
.
VolumeSource
.
RBD
!=
nil
{
return
spec
.
VolumeSource
.
RBD
}
else
{
...
...
@@ -105,7 +105,7 @@ func (plugin *RBDPlugin) getRBDVolumeSource(spec *volume.Spec) *api.RBDVolumeSou
}
}
func
(
plugin
*
RBD
Plugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
secret
string
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
rbd
Plugin
)
newBuilderInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
secret
string
)
(
volume
.
Builder
,
error
)
{
source
:=
plugin
.
getRBDVolumeSource
(
spec
)
pool
:=
source
.
RBDPool
if
pool
==
""
{
...
...
@@ -137,12 +137,12 @@ func (plugin *RBDPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID,
},
nil
}
func
(
plugin
*
RBD
Plugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
rbd
Plugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
// Inject real implementations here, test through the internal function.
return
plugin
.
newCleanerInternal
(
volName
,
podUID
,
&
RBDUtil
{},
mounter
)
}
func
(
plugin
*
RBD
Plugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
rbd
Plugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
return
&
rbd
{
podUID
:
podUID
,
volName
:
volName
,
...
...
@@ -163,14 +163,14 @@ type rbd struct {
secret
string
fsType
string
readOnly
bool
plugin
*
RBD
Plugin
plugin
*
rbd
Plugin
mounter
mount
.
Interface
// Utility interface that provides API calls to the provider to attach/detach disks.
manager
diskManager
}
func
(
rbd
*
rbd
)
GetPath
()
string
{
name
:=
RBD
PluginName
name
:=
rbd
PluginName
// safe to use PodVolumeDir now: volume teardown occurs before pod is cleaned up
return
rbd
.
plugin
.
host
.
GetPodVolumeDir
(
rbd
.
podUID
,
util
.
EscapeQualifiedNameForDisk
(
name
),
rbd
.
volName
)
}
...
...
@@ -208,7 +208,7 @@ func (rbd *rbd) TearDownAt(dir string) error {
return
diskTearDown
(
rbd
.
manager
,
*
rbd
,
dir
,
rbd
.
mounter
)
}
func
(
plugin
*
RBD
Plugin
)
execCommand
(
command
string
,
args
[]
string
)
([]
byte
,
error
)
{
func
(
plugin
*
rbd
Plugin
)
execCommand
(
command
string
,
args
[]
string
)
([]
byte
,
error
)
{
cmd
:=
plugin
.
exe
.
Command
(
command
,
args
...
)
return
cmd
.
CombinedOutput
()
}
pkg/volume/rbd/rbd_test.go
View file @
fe6399a6
...
...
@@ -73,7 +73,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
builder
,
err
:=
plug
.
(
*
RBD
Plugin
)
.
newBuilderInternal
(
spec
,
types
.
UID
(
"poduid"
),
&
fakeDiskManager
{},
&
mount
.
FakeMounter
{},
"secrets"
)
builder
,
err
:=
plug
.
(
*
rbd
Plugin
)
.
newBuilderInternal
(
spec
,
types
.
UID
(
"poduid"
),
&
fakeDiskManager
{},
&
mount
.
FakeMounter
{},
"secrets"
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
...
...
@@ -104,7 +104,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
}
}
cleaner
,
err
:=
plug
.
(
*
RBD
Plugin
)
.
newCleanerInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
&
fakeDiskManager
{},
&
mount
.
FakeMounter
{})
cleaner
,
err
:=
plug
.
(
*
rbd
Plugin
)
.
newCleanerInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
&
fakeDiskManager
{},
&
mount
.
FakeMounter
{})
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Cleaner: %v"
,
err
)
}
...
...
pkg/volume/rbd/rbd_util.go
View file @
fe6399a6
...
...
@@ -52,7 +52,7 @@ func waitForPathToExist(devicePath string, maxRetries int) bool {
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/pod/rbd/pool-image-image
func
makePDNameInternal
(
host
volume
.
VolumeHost
,
pool
string
,
image
string
)
string
{
return
path
.
Join
(
host
.
GetPluginDir
(
RBD
PluginName
),
"rbd"
,
pool
+
"-image-"
+
image
)
return
path
.
Join
(
host
.
GetPluginDir
(
rbd
PluginName
),
"rbd"
,
pool
+
"-image-"
+
image
)
}
type
RBDUtil
struct
{}
...
...
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