Merge pull request #40317 from kpgriffith/recycle-vol-plug-cleanup

Automatic merge from submit-queue (batch tested with PRs 41364, 40317, 41326, 41783, 41782)

changes to cleanup the volume plugin for recycle

**What this PR does / why we need it**:
Code cleanup. Changing from creating a new interface from the plugin, that then calls a function to recycle a volume, to adding the function to the plugin itself.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #26230

**Special notes for your reviewer**:
Took same approach from closed PR #28432.

Do you want the approach to be the same for NewDeleter(), NewMounter(), NewUnMounter() and should they be in this same PR or submit different PR's for those?

**Release note**:

```NONE
```
This commit is contained in:
Kubernetes Submit Queue
2017-02-21 07:45:40 -08:00
committed by GitHub
12 changed files with 56 additions and 208 deletions

View File

@@ -1226,17 +1226,11 @@ func (plugin *mockVolumePlugin) GetMetrics() (*vol.Metrics, error) {
// Recycler interfaces
func (plugin *mockVolumePlugin) NewRecycler(pvName string, spec *vol.Spec, eventRecorder vol.RecycleEventRecorder) (vol.Recycler, error) {
if len(plugin.recycleCalls) > 0 {
// mockVolumePlugin directly implements Recycler interface
glog.V(4).Infof("mock plugin NewRecycler called, returning mock recycler")
return plugin, nil
} else {
return nil, fmt.Errorf("Mock plugin error: no recycleCalls configured")
func (plugin *mockVolumePlugin) Recycle(pvName string, spec *vol.Spec, eventRecorder vol.RecycleEventRecorder) error {
if len(plugin.recycleCalls) == 0 {
return fmt.Errorf("Mock plugin error: no recycleCalls configured")
}
}
func (plugin *mockVolumePlugin) Recycle() error {
if len(plugin.recycleCalls) <= plugin.recycleCallCounter {
return fmt.Errorf("Mock plugin error: unexpected recycle call %d", plugin.recycleCallCounter)
}