Skip to content

Commit

Permalink
added check to recycler to insure PV is Released, added test for same
Browse files Browse the repository at this point in the history
  • Loading branch information
markturansky committed May 29, 2015
1 parent 4c1a5a9 commit 4214c1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/volumeclaimbinder/persistent_volume_claim_binder_test.go
Expand Up @@ -249,6 +249,8 @@ func TestBindingWithExamples(t *testing.T) {
t.Errorf("Expected non-nil ClaimRef: %+v", pv.Spec)
}

mockClient.volume = pv

// released volumes with a PersistentVolumeReclaimPolicy (recycle/delete) can have further processing
err = recycler.reclaimVolume(pv)
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion pkg/volumeclaimbinder/persistent_volume_recycler.go
Expand Up @@ -87,10 +87,18 @@ func (recycler *PersistentVolumeRecycler) reclaimVolume(pv *api.PersistentVolume
if pv.Status.Phase == api.VolumeReleased && pv.Spec.ClaimRef != nil {
glog.V(5).Infof("Reclaiming PersistentVolume[%s]\n", pv.Name)

latest, err := recycler.client.GetPersistentVolume(pv.Name)
if err != nil {
return fmt.Errorf("Could not find PersistentVolume %s", pv.Name)
}
if latest.Status.Phase != api.VolumeReleased {
return fmt.Errorf("PersistentVolume[%s] phase is %s, expected %s. Skipping.", pv.Name, latest.Status.Phase, api.VolumeReleased)
}

// both handleRecycle and handleDelete block until completion
// TODO: allow parallel recycling operations to increase throughput

var err error
// var err error
switch pv.Spec.PersistentVolumeReclaimPolicy {
case api.PersistentVolumeReclaimRecycle:
err = recycler.handleRecycle(pv)
Expand Down

0 comments on commit 4214c1b

Please sign in to comment.