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
666739ac
Unverified
Commit
666739ac
authored
Nov 16, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 16, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70580 from tsmetana/check-pvc-binding-again
PV Controller: fix recycling
parents
973b5d29
f9c9ef6e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
pv_controller.go
pkg/controller/volume/persistentvolume/pv_controller.go
+13
-1
recycle_test.go
pkg/controller/volume/persistentvolume/recycle_test.go
+10
-0
No files found.
pkg/controller/volume/persistentvolume/pv_controller.go
View file @
666739ac
...
@@ -1127,7 +1127,19 @@ func (ctrl *PersistentVolumeController) recycleVolumeOperation(volume *v1.Persis
...
@@ -1127,7 +1127,19 @@ func (ctrl *PersistentVolumeController) recycleVolumeOperation(volume *v1.Persis
klog
.
V
(
3
)
.
Infof
(
"can't recycle volume %q: %v"
,
volume
.
Name
,
err
)
klog
.
V
(
3
)
.
Infof
(
"can't recycle volume %q: %v"
,
volume
.
Name
,
err
)
return
return
}
}
if
used
{
// Verify the claim is in cache: if so, then it is a different PVC with the same name
// since the volume is known to be released at this moment. Ths new (cached) PVC must use
// a different PV -- we checked that the PV is unused in isVolumeReleased.
// So the old PV is safe to be recycled.
claimName
:=
claimrefToClaimKey
(
volume
.
Spec
.
ClaimRef
)
_
,
claimCached
,
err
:=
ctrl
.
claims
.
GetByKey
(
claimName
)
if
err
!=
nil
{
klog
.
V
(
3
)
.
Infof
(
"error getting the claim %s from cache"
,
claimName
)
return
}
if
used
&&
!
claimCached
{
msg
:=
fmt
.
Sprintf
(
"Volume is used by pods: %s"
,
strings
.
Join
(
pods
,
","
))
msg
:=
fmt
.
Sprintf
(
"Volume is used by pods: %s"
,
strings
.
Join
(
pods
,
","
))
klog
.
V
(
3
)
.
Infof
(
"can't recycle volume %q: %s"
,
volume
.
Name
,
msg
)
klog
.
V
(
3
)
.
Infof
(
"can't recycle volume %q: %s"
,
volume
.
Name
,
msg
)
ctrl
.
eventRecorder
.
Event
(
volume
,
v1
.
EventTypeNormal
,
events
.
VolumeFailedRecycle
,
msg
)
ctrl
.
eventRecorder
.
Event
(
volume
,
v1
.
EventTypeNormal
,
events
.
VolumeFailedRecycle
,
msg
)
...
...
pkg/controller/volume/persistentvolume/recycle_test.go
View file @
666739ac
...
@@ -229,6 +229,16 @@ func TestRecycleSync(t *testing.T) {
...
@@ -229,6 +229,16 @@ func TestRecycleSync(t *testing.T) {
// recycler simulates one recycle() call that succeeds.
// recycler simulates one recycle() call that succeeds.
wrapTestWithReclaimCalls
(
operationRecycle
,
[]
error
{
nil
},
testSyncVolume
),
wrapTestWithReclaimCalls
(
operationRecycle
,
[]
error
{
nil
},
testSyncVolume
),
},
},
{
// volume is used by a completed pod, pod using claim with the same name bound to different pv is running, should recycle
"6-14 - seemingly used by running pod"
,
newVolumeArray
(
"volume6-14"
,
"1Gi"
,
"uid6-14"
,
"completedClaim"
,
v1
.
VolumeBound
,
v1
.
PersistentVolumeReclaimRecycle
,
classEmpty
,
annBoundByController
),
newVolumeArray
(
"volume6-14"
,
"1Gi"
,
""
,
""
,
v1
.
VolumeAvailable
,
v1
.
PersistentVolumeReclaimRecycle
,
classEmpty
),
newClaimArray
(
"completedClaim"
,
"uid6-14-x"
,
"10Gi"
,
""
,
v1
.
ClaimBound
,
nil
),
newClaimArray
(
"completedClaim"
,
"uid6-14-x"
,
"10Gi"
,
""
,
v1
.
ClaimBound
,
nil
),
noevents
,
noerrors
,
wrapTestWithReclaimCalls
(
operationRecycle
,
[]
error
{
nil
},
testSyncVolume
),
},
}
}
runSyncTests
(
t
,
tests
,
[]
*
storage
.
StorageClass
{},
pods
)
runSyncTests
(
t
,
tests
,
[]
*
storage
.
StorageClass
{},
pods
)
}
}
...
...
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