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
c7e619d4
Commit
c7e619d4
authored
Mar 10, 2015
by
markturansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change volume.NewBuild arg from podUID to ObjectReference
parent
7aa060ba
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
39 additions
and
33 deletions
+39
-33
empty_dir.go
pkg/kubelet/volume/empty_dir/empty_dir.go
+2
-2
empty_dir_test.go
pkg/kubelet/volume/empty_dir/empty_dir_test.go
+3
-3
gce_pd.go
pkg/kubelet/volume/gce_pd/gce_pd.go
+2
-2
gce_pd_test.go
pkg/kubelet/volume/gce_pd/gce_pd_test.go
+1
-1
git_repo.go
pkg/kubelet/volume/git_repo/git_repo.go
+2
-2
git_repo_test.go
pkg/kubelet/volume/git_repo/git_repo_test.go
+2
-2
host_path.go
pkg/kubelet/volume/host_path/host_path.go
+1
-1
host_path_test.go
pkg/kubelet/volume/host_path/host_path_test.go
+1
-1
plugins.go
pkg/kubelet/volume/plugins.go
+2
-2
secret.go
pkg/kubelet/volume/secret/secret.go
+10
-10
secret_test.go
pkg/kubelet/volume/secret/secret_test.go
+1
-1
testing.go
pkg/kubelet/volume/testing.go
+2
-2
volumes.go
pkg/kubelet/volumes.go
+10
-4
No files found.
pkg/kubelet/volume/empty_dir/empty_dir.go
View file @
c7e619d4
...
@@ -69,12 +69,12 @@ func (plugin *emptyDirPlugin) CanSupport(spec *api.Volume) bool {
...
@@ -69,12 +69,12 @@ func (plugin *emptyDirPlugin) CanSupport(spec *api.Volume) bool {
return
false
return
false
}
}
func
(
plugin
*
emptyDirPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
emptyDirPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
if
plugin
.
legacyMode
{
if
plugin
.
legacyMode
{
// Legacy mode instances can be cleaned up but not created anew.
// Legacy mode instances can be cleaned up but not created anew.
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
}
}
return
&
emptyDir
{
podUID
,
spec
.
Name
,
plugin
,
false
},
nil
return
&
emptyDir
{
pod
Ref
.
UID
,
spec
.
Name
,
plugin
,
false
},
nil
}
}
func
(
plugin
*
emptyDirPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
emptyDirPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
...
...
pkg/kubelet/volume/empty_dir/empty_dir_test.go
View file @
c7e619d4
...
@@ -56,7 +56,7 @@ func TestPlugin(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestPlugin(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
)
)
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -109,7 +109,7 @@ func TestPluginBackCompat(t *testing.T) {
...
@@ -109,7 +109,7 @@ func TestPluginBackCompat(t *testing.T) {
spec
:=
&
api
.
Volume
{
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Name
:
"vol1"
,
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
)
)
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -138,7 +138,7 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -138,7 +138,7 @@ func TestPluginLegacy(t *testing.T) {
t
.
Errorf
(
"Expected false"
)
t
.
Errorf
(
"Expected false"
)
}
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
types
.
UID
(
"poduid"
)
);
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
);
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/kubelet/volume/gce_pd/gce_pd.go
View file @
c7e619d4
...
@@ -70,9 +70,9 @@ func (plugin *gcePersistentDiskPlugin) CanSupport(spec *api.Volume) bool {
...
@@ -70,9 +70,9 @@ func (plugin *gcePersistentDiskPlugin) CanSupport(spec *api.Volume) bool {
return
false
return
false
}
}
func
(
plugin
*
gcePersistentDiskPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gcePersistentDiskPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newBuilderInternal
(
spec
,
podUID
,
&
GCEDiskUtil
{},
mount
.
New
())
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
.
UID
,
&
GCEDiskUtil
{},
mount
.
New
())
}
}
func
(
plugin
*
gcePersistentDiskPlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gcePersistentDiskPlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
...
...
pkg/kubelet/volume/gce_pd/gce_pd_test.go
View file @
c7e619d4
...
@@ -145,7 +145,7 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -145,7 +145,7 @@ func TestPluginLegacy(t *testing.T) {
t
.
Errorf
(
"Expected false"
)
t
.
Errorf
(
"Expected false"
)
}
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}},
types
.
UID
(
"poduid"
)
);
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}},
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
);
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/kubelet/volume/git_repo/git_repo.go
View file @
c7e619d4
...
@@ -69,13 +69,13 @@ func (plugin *gitRepoPlugin) CanSupport(spec *api.Volume) bool {
...
@@ -69,13 +69,13 @@ func (plugin *gitRepoPlugin) CanSupport(spec *api.Volume) bool {
return
false
return
false
}
}
func
(
plugin
*
gitRepoPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
gitRepoPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
if
plugin
.
legacyMode
{
if
plugin
.
legacyMode
{
// Legacy mode instances can be cleaned up but not created anew.
// Legacy mode instances can be cleaned up but not created anew.
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
}
}
return
&
gitRepo
{
return
&
gitRepo
{
podUID
:
podUID
,
podUID
:
pod
Ref
.
UID
,
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
source
:
spec
.
GitRepo
.
Repository
,
source
:
spec
.
GitRepo
.
Repository
,
revision
:
spec
.
GitRepo
.
Revision
,
revision
:
spec
.
GitRepo
.
Revision
,
...
...
pkg/kubelet/volume/git_repo/git_repo_test.go
View file @
c7e619d4
...
@@ -117,7 +117,7 @@ func TestPlugin(t *testing.T) {
...
@@ -117,7 +117,7 @@ func TestPlugin(t *testing.T) {
},
},
},
},
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
)
)
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
@@ -172,7 +172,7 @@ func TestPluginLegacy(t *testing.T) {
...
@@ -172,7 +172,7 @@ func TestPluginLegacy(t *testing.T) {
t
.
Errorf
(
"Expected false"
)
t
.
Errorf
(
"Expected false"
)
}
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}},
types
.
UID
(
"poduid"
)
);
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}},
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
);
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
t
.
Errorf
(
"Expected failiure"
)
}
}
...
...
pkg/kubelet/volume/host_path/host_path.go
View file @
c7e619d4
...
@@ -52,7 +52,7 @@ func (plugin *hostPathPlugin) CanSupport(spec *api.Volume) bool {
...
@@ -52,7 +52,7 @@ func (plugin *hostPathPlugin) CanSupport(spec *api.Volume) bool {
return
false
return
false
}
}
func
(
plugin
*
hostPathPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
hostPathPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
return
&
hostPath
{
spec
.
HostPath
.
Path
},
nil
return
&
hostPath
{
spec
.
HostPath
.
Path
},
nil
}
}
...
...
pkg/kubelet/volume/host_path/host_path_test.go
View file @
c7e619d4
...
@@ -55,7 +55,7 @@ func TestPlugin(t *testing.T) {
...
@@ -55,7 +55,7 @@ func TestPlugin(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
}
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
)
)
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
"poduid"
)}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
...
pkg/kubelet/volume/plugins.go
View file @
c7e619d4
...
@@ -49,8 +49,8 @@ type Plugin interface {
...
@@ -49,8 +49,8 @@ type Plugin interface {
// NewBuilder creates a new volume.Builder from an API specification.
// NewBuilder creates a new volume.Builder from an API specification.
// Ownership of the spec pointer in *not* transferred.
// Ownership of the spec pointer in *not* transferred.
// - spec: The api.Volume spec
// - spec: The api.Volume spec
// - pod
UID: The UID of
the enclosing pod
// - pod
Ref: a reference to
the enclosing pod
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
Builder
,
error
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
Builder
,
error
)
// NewCleaner creates a new volume.Cleaner from recoverable state.
// NewCleaner creates a new volume.Cleaner from recoverable state.
// - name: The volume name, as per the api.Volume spec.
// - name: The volume name, as per the api.Volume spec.
...
...
pkg/kubelet/volume/secret/secret.go
View file @
c7e619d4
...
@@ -58,12 +58,12 @@ func (plugin *secretPlugin) CanSupport(spec *api.Volume) bool {
...
@@ -58,12 +58,12 @@ func (plugin *secretPlugin) CanSupport(spec *api.Volume) bool {
return
false
return
false
}
}
func
(
plugin
*
secretPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
secretPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
return
plugin
.
newBuilderInternal
(
spec
,
pod
UID
)
return
plugin
.
newBuilderInternal
(
spec
,
pod
Ref
)
}
}
func
(
plugin
*
secretPlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
secretPlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
volume
.
Builder
,
error
)
{
return
&
secretVolume
{
spec
.
Name
,
pod
UID
,
plugin
,
&
spec
.
Secret
.
Target
},
nil
return
&
secretVolume
{
spec
.
Name
,
pod
Ref
,
plugin
,
&
spec
.
Secret
.
Target
},
nil
}
}
func
(
plugin
*
secretPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
secretPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
...
@@ -71,14 +71,14 @@ func (plugin *secretPlugin) NewCleaner(volName string, podUID types.UID) (volume
...
@@ -71,14 +71,14 @@ func (plugin *secretPlugin) NewCleaner(volName string, podUID types.UID) (volume
}
}
func
(
plugin
*
secretPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
func
(
plugin
*
secretPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
return
&
secretVolume
{
volName
,
podUID
,
plugin
,
nil
},
nil
return
&
secretVolume
{
volName
,
&
api
.
ObjectReference
{
UID
:
podUID
}
,
plugin
,
nil
},
nil
}
}
// secretVolume handles retrieving secrets from the API server
// secretVolume handles retrieving secrets from the API server
// and placing them into the volume on the host.
// and placing them into the volume on the host.
type
secretVolume
struct
{
type
secretVolume
struct
{
volName
string
volName
string
pod
UID
types
.
UID
pod
Ref
*
api
.
ObjectReference
plugin
*
secretPlugin
plugin
*
secretPlugin
secretRef
*
api
.
ObjectReference
secretRef
*
api
.
ObjectReference
}
}
...
@@ -86,7 +86,7 @@ type secretVolume struct {
...
@@ -86,7 +86,7 @@ type secretVolume struct {
func
(
sv
*
secretVolume
)
SetUp
()
error
{
func
(
sv
*
secretVolume
)
SetUp
()
error
{
// TODO: explore tmpfs for secret volumes
// TODO: explore tmpfs for secret volumes
hostPath
:=
sv
.
GetPath
()
hostPath
:=
sv
.
GetPath
()
glog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
podUID
,
hostPath
)
glog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
Ref
.
UID
,
hostPath
)
err
:=
os
.
MkdirAll
(
hostPath
,
0777
)
err
:=
os
.
MkdirAll
(
hostPath
,
0777
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -97,7 +97,7 @@ func (sv *secretVolume) SetUp() error {
...
@@ -97,7 +97,7 @@ func (sv *secretVolume) SetUp() error {
return
fmt
.
Errorf
(
"Cannot setup secret volume %v because kube client is not configured"
,
sv
)
return
fmt
.
Errorf
(
"Cannot setup secret volume %v because kube client is not configured"
,
sv
)
}
}
secret
,
err
:=
kubeClient
.
Secrets
(
sv
.
secret
Ref
.
Namespace
)
.
Get
(
sv
.
secretRef
.
Name
)
secret
,
err
:=
kubeClient
.
Secrets
(
sv
.
pod
Ref
.
Namespace
)
.
Get
(
sv
.
secretRef
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Couldn't get secret %v/%v"
,
sv
.
secretRef
.
Namespace
,
sv
.
secretRef
.
Name
)
glog
.
Errorf
(
"Couldn't get secret %v/%v"
,
sv
.
secretRef
.
Namespace
,
sv
.
secretRef
.
Name
)
return
err
return
err
...
@@ -116,11 +116,11 @@ func (sv *secretVolume) SetUp() error {
...
@@ -116,11 +116,11 @@ func (sv *secretVolume) SetUp() error {
}
}
func
(
sv
*
secretVolume
)
GetPath
()
string
{
func
(
sv
*
secretVolume
)
GetPath
()
string
{
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
podUID
,
volume
.
EscapePluginName
(
secretPluginName
),
sv
.
volName
)
return
sv
.
plugin
.
host
.
GetPodVolumeDir
(
sv
.
pod
Ref
.
UID
,
volume
.
EscapePluginName
(
secretPluginName
),
sv
.
volName
)
}
}
func
(
sv
*
secretVolume
)
TearDown
()
error
{
func
(
sv
*
secretVolume
)
TearDown
()
error
{
glog
.
V
(
3
)
.
Infof
(
"Tearing down volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
podUID
,
sv
.
GetPath
())
glog
.
V
(
3
)
.
Infof
(
"Tearing down volume %v for pod %v at %v"
,
sv
.
volName
,
sv
.
pod
Ref
.
UID
,
sv
.
GetPath
())
tmpDir
,
err
:=
volume
.
RenameDirectory
(
sv
.
GetPath
(),
sv
.
volName
+
".deleting~"
)
tmpDir
,
err
:=
volume
.
RenameDirectory
(
sv
.
GetPath
(),
sv
.
volName
+
".deleting~"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubelet/volume/secret/secret_test.go
View file @
c7e619d4
...
@@ -99,7 +99,7 @@ func TestPlugin(t *testing.T) {
...
@@ -99,7 +99,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Can't find the plugin by name"
)
t
.
Errorf
(
"Can't find the plugin by name"
)
}
}
builder
,
err
:=
plugin
.
NewBuilder
(
volumeSpec
,
types
.
UID
(
testPodUID
)
)
builder
,
err
:=
plugin
.
NewBuilder
(
volumeSpec
,
&
api
.
ObjectReference
{
UID
:
types
.
UID
(
testPodUID
)}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
t
.
Errorf
(
"Failed to make a new Builder: %v"
,
err
)
}
}
...
...
pkg/kubelet/volume/testing.go
View file @
c7e619d4
...
@@ -71,8 +71,8 @@ func (plugin *FakePlugin) CanSupport(spec *api.Volume) bool {
...
@@ -71,8 +71,8 @@ func (plugin *FakePlugin) CanSupport(spec *api.Volume) bool {
return
true
return
true
}
}
func
(
plugin
*
FakePlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
(
Builder
,
error
)
{
func
(
plugin
*
FakePlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
(
Builder
,
error
)
{
return
&
FakeVolume
{
podUID
,
spec
.
Name
,
plugin
},
nil
return
&
FakeVolume
{
pod
Ref
.
UID
,
spec
.
Name
,
plugin
},
nil
}
}
func
(
plugin
*
FakePlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
Cleaner
,
error
)
{
func
(
plugin
*
FakePlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
Cleaner
,
error
)
{
...
...
pkg/kubelet/volumes.go
View file @
c7e619d4
...
@@ -53,7 +53,7 @@ func (vh *volumeHost) GetKubeClient() client.Interface {
...
@@ -53,7 +53,7 @@ func (vh *volumeHost) GetKubeClient() client.Interface {
return
vh
.
kubelet
.
kubeClient
return
vh
.
kubelet
.
kubeClient
}
}
func
(
kl
*
Kubelet
)
newVolumeBuilderFromPlugins
(
spec
*
api
.
Volume
,
pod
UID
types
.
UID
)
volume
.
Builder
{
func
(
kl
*
Kubelet
)
newVolumeBuilderFromPlugins
(
spec
*
api
.
Volume
,
pod
Ref
*
api
.
ObjectReference
)
volume
.
Builder
{
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginBySpec
(
spec
)
plugin
,
err
:=
kl
.
volumePluginMgr
.
FindPluginBySpec
(
spec
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Warningf
(
"Can't use volume plugins for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
glog
.
Warningf
(
"Can't use volume plugins for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
...
@@ -63,7 +63,7 @@ func (kl *Kubelet) newVolumeBuilderFromPlugins(spec *api.Volume, podUID types.UI
...
@@ -63,7 +63,7 @@ func (kl *Kubelet) newVolumeBuilderFromPlugins(spec *api.Volume, podUID types.UI
glog
.
Errorf
(
"No error, but nil volume plugin for %s"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
))
glog
.
Errorf
(
"No error, but nil volume plugin for %s"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
))
return
nil
return
nil
}
}
builder
,
err
:=
plugin
.
NewBuilder
(
spec
,
pod
UID
)
builder
,
err
:=
plugin
.
NewBuilder
(
spec
,
pod
Ref
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Warningf
(
"Error instantiating volume plugin for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
glog
.
Warningf
(
"Error instantiating volume plugin for %s: %v"
,
spew
.
Sprintf
(
"%#v"
,
*
spec
),
err
)
return
nil
return
nil
...
@@ -77,12 +77,18 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.BoundPod) (volumeMap, error) {
...
@@ -77,12 +77,18 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.BoundPod) (volumeMap, error) {
for
i
:=
range
pod
.
Spec
.
Volumes
{
for
i
:=
range
pod
.
Spec
.
Volumes
{
volSpec
:=
&
pod
.
Spec
.
Volumes
[
i
]
volSpec
:=
&
pod
.
Spec
.
Volumes
[
i
]
podRef
,
err
:=
api
.
GetReference
(
pod
)
if
err
!=
nil
{
glog
.
Errorf
(
"Error getting object reference for pod: %v"
,
pod
,
err
)
return
nil
,
err
}
// Try to use a plugin for this volume.
// Try to use a plugin for this volume.
builder
:=
kl
.
newVolumeBuilderFromPlugins
(
volSpec
,
pod
.
UID
)
builder
:=
kl
.
newVolumeBuilderFromPlugins
(
volSpec
,
pod
Ref
)
if
builder
==
nil
{
if
builder
==
nil
{
return
nil
,
errUnsupportedVolumeType
return
nil
,
errUnsupportedVolumeType
}
}
err
:
=
builder
.
SetUp
()
err
=
builder
.
SetUp
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
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