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
ad7ed679
Commit
ad7ed679
authored
Feb 12, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20213 from jsafrane/devel/pv-reload
Auto commit by PR queue bot
parents
678958a7
e2826626
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
1 deletion
+25
-1
persistentvolume_claim_binder_controller.go
...sistentvolume/persistentvolume_claim_binder_controller.go
+11
-0
persistentvolume_claim_binder_controller_test.go
...ntvolume/persistentvolume_claim_binder_controller_test.go
+2
-0
persistentvolume_provisioner_controller.go
...rsistentvolume/persistentvolume_provisioner_controller.go
+9
-1
persistentvolume_provisioner_controller_test.go
...entvolume/persistentvolume_provisioner_controller_test.go
+3
-0
No files found.
pkg/controller/persistentvolume/persistentvolume_claim_binder_controller.go
View file @
ad7ed679
...
@@ -193,6 +193,14 @@ func (binder *PersistentVolumeClaimBinder) deleteClaim(obj interface{}) {
...
@@ -193,6 +193,14 @@ func (binder *PersistentVolumeClaimBinder) deleteClaim(obj interface{}) {
func
syncVolume
(
volumeIndex
*
persistentVolumeOrderedIndex
,
binderClient
binderClient
,
volume
*
api
.
PersistentVolume
)
(
err
error
)
{
func
syncVolume
(
volumeIndex
*
persistentVolumeOrderedIndex
,
binderClient
binderClient
,
volume
*
api
.
PersistentVolume
)
(
err
error
)
{
glog
.
V
(
5
)
.
Infof
(
"Synchronizing PersistentVolume[%s], current phase: %s
\n
"
,
volume
.
Name
,
volume
.
Status
.
Phase
)
glog
.
V
(
5
)
.
Infof
(
"Synchronizing PersistentVolume[%s], current phase: %s
\n
"
,
volume
.
Name
,
volume
.
Status
.
Phase
)
// The PV may have been modified by parallel call to syncVolume, load
// the current version.
newPv
,
err
:=
binderClient
.
GetPersistentVolume
(
volume
.
Name
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Cannot reload volume %s: %v"
,
volume
.
Name
,
err
)
}
volume
=
newPv
// volumes can be in one of the following states:
// volumes can be in one of the following states:
//
//
// VolumePending -- default value -- not bound to a claim and not yet processed through this controller.
// VolumePending -- default value -- not bound to a claim and not yet processed through this controller.
...
@@ -203,12 +211,15 @@ func syncVolume(volumeIndex *persistentVolumeOrderedIndex, binderClient binderCl
...
@@ -203,12 +211,15 @@ func syncVolume(volumeIndex *persistentVolumeOrderedIndex, binderClient binderCl
currentPhase
:=
volume
.
Status
.
Phase
currentPhase
:=
volume
.
Status
.
Phase
nextPhase
:=
currentPhase
nextPhase
:=
currentPhase
// Always store the newest volume state in local cache.
_
,
exists
,
err
:=
volumeIndex
.
Get
(
volume
)
_
,
exists
,
err
:=
volumeIndex
.
Get
(
volume
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
!
exists
{
if
!
exists
{
volumeIndex
.
Add
(
volume
)
volumeIndex
.
Add
(
volume
)
}
else
{
volumeIndex
.
Update
(
volume
)
}
}
if
isBeingProvisioned
(
volume
)
{
if
isBeingProvisioned
(
volume
)
{
...
...
pkg/controller/persistentvolume/persistentvolume_claim_binder_controller_test.go
View file @
ad7ed679
...
@@ -120,6 +120,7 @@ func TestClaimRace(t *testing.T) {
...
@@ -120,6 +120,7 @@ func TestClaimRace(t *testing.T) {
volumeIndex
:=
NewPersistentVolumeOrderedIndex
()
volumeIndex
:=
NewPersistentVolumeOrderedIndex
()
mockClient
:=
&
mockBinderClient
{}
mockClient
:=
&
mockBinderClient
{}
mockClient
.
volume
=
v
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
.
InitPlugins
(
host_path
.
ProbeRecyclableVolumePlugins
(
newMockRecycler
,
volume
.
VolumeConfig
{}),
volume
.
NewFakeVolumeHost
(
tmpDir
,
nil
,
nil
))
plugMgr
.
InitPlugins
(
host_path
.
ProbeRecyclableVolumePlugins
(
newMockRecycler
,
volume
.
VolumeConfig
{}),
volume
.
NewFakeVolumeHost
(
tmpDir
,
nil
,
nil
))
...
@@ -277,6 +278,7 @@ func TestClaimSyncAfterVolumeProvisioning(t *testing.T) {
...
@@ -277,6 +278,7 @@ func TestClaimSyncAfterVolumeProvisioning(t *testing.T) {
volumeIndex
:=
NewPersistentVolumeOrderedIndex
()
volumeIndex
:=
NewPersistentVolumeOrderedIndex
()
mockClient
:=
&
mockBinderClient
{
mockClient
:=
&
mockBinderClient
{
claim
:
claim
,
claim
:
claim
,
volume
:
pv
,
}
}
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
:=
volume
.
VolumePluginMgr
{}
...
...
pkg/controller/persistentvolume/persistentvolume_provisioner_controller.go
View file @
ad7ed679
...
@@ -225,6 +225,14 @@ func (controller *PersistentVolumeProvisionerController) reconcileClaim(claim *a
...
@@ -225,6 +225,14 @@ func (controller *PersistentVolumeProvisionerController) reconcileClaim(claim *a
func
(
controller
*
PersistentVolumeProvisionerController
)
reconcileVolume
(
pv
*
api
.
PersistentVolume
)
error
{
func
(
controller
*
PersistentVolumeProvisionerController
)
reconcileVolume
(
pv
*
api
.
PersistentVolume
)
error
{
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] reconciling"
,
pv
.
Name
)
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] reconciling"
,
pv
.
Name
)
// The PV may have been modified by parallel call to reconcileVolume, load
// the current version.
newPv
,
err
:=
controller
.
client
.
GetPersistentVolume
(
pv
.
Name
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Cannot reload volume %s: %v"
,
pv
.
Name
,
err
)
}
pv
=
newPv
if
pv
.
Spec
.
ClaimRef
==
nil
{
if
pv
.
Spec
.
ClaimRef
==
nil
{
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] is not bound to a claim. No provisioning required"
,
pv
.
Name
)
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] is not bound to a claim. No provisioning required"
,
pv
.
Name
)
return
nil
return
nil
...
@@ -258,7 +266,7 @@ func (controller *PersistentVolumeProvisionerController) reconcileVolume(pv *api
...
@@ -258,7 +266,7 @@ func (controller *PersistentVolumeProvisionerController) reconcileVolume(pv *api
// provisioning is incomplete. Attempt to provision the volume.
// provisioning is incomplete. Attempt to provision the volume.
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] provisioning in progress"
,
pv
.
Name
)
glog
.
V
(
5
)
.
Infof
(
"PersistentVolume[%s] provisioning in progress"
,
pv
.
Name
)
err
:
=
provisionVolume
(
pv
,
controller
)
err
=
provisionVolume
(
pv
,
controller
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error provisioning PersistentVolume[%s]: %v"
,
pv
.
Name
,
err
)
return
fmt
.
Errorf
(
"Error provisioning PersistentVolume[%s]: %v"
,
pv
.
Name
,
err
)
}
}
...
...
pkg/controller/persistentvolume/persistentvolume_provisioner_controller_test.go
View file @
ad7ed679
...
@@ -183,6 +183,7 @@ func TestReconcileVolume(t *testing.T) {
...
@@ -183,6 +183,7 @@ func TestReconcileVolume(t *testing.T) {
controller
,
mockClient
,
mockVolumePlugin
:=
makeTestController
()
controller
,
mockClient
,
mockVolumePlugin
:=
makeTestController
()
pv
:=
makeTestVolume
()
pv
:=
makeTestVolume
()
pvc
:=
makeTestClaim
()
pvc
:=
makeTestClaim
()
mockClient
.
volume
=
pv
err
:=
controller
.
reconcileVolume
(
pv
)
err
:=
controller
.
reconcileVolume
(
pv
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -197,6 +198,7 @@ func TestReconcileVolume(t *testing.T) {
...
@@ -197,6 +198,7 @@ func TestReconcileVolume(t *testing.T) {
// pretend the claim and volume are bound, no provisioning required
// pretend the claim and volume are bound, no provisioning required
claimRef
,
_
:=
api
.
GetReference
(
pvc
)
claimRef
,
_
:=
api
.
GetReference
(
pvc
)
pv
.
Spec
.
ClaimRef
=
claimRef
pv
.
Spec
.
ClaimRef
=
claimRef
mockClient
.
volume
=
pv
err
=
controller
.
reconcileVolume
(
pv
)
err
=
controller
.
reconcileVolume
(
pv
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error %v"
,
err
)
t
.
Errorf
(
"Unexpected error %v"
,
err
)
...
@@ -204,6 +206,7 @@ func TestReconcileVolume(t *testing.T) {
...
@@ -204,6 +206,7 @@ func TestReconcileVolume(t *testing.T) {
pv
.
Annotations
[
pvProvisioningRequiredAnnotationKey
]
=
"!pvProvisioningCompleted"
pv
.
Annotations
[
pvProvisioningRequiredAnnotationKey
]
=
"!pvProvisioningCompleted"
pv
.
Annotations
[
qosProvisioningKey
]
=
"foo"
pv
.
Annotations
[
qosProvisioningKey
]
=
"foo"
mockClient
.
volume
=
pv
err
=
controller
.
reconcileVolume
(
pv
)
err
=
controller
.
reconcileVolume
(
pv
)
if
!
isAnnotationMatch
(
pvProvisioningRequiredAnnotationKey
,
pvProvisioningCompletedAnnotationValue
,
mockClient
.
volume
.
Annotations
)
{
if
!
isAnnotationMatch
(
pvProvisioningRequiredAnnotationKey
,
pvProvisioningCompletedAnnotationValue
,
mockClient
.
volume
.
Annotations
)
{
...
...
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