Merge pull request #51114 from jsafrane/exec-rbd

Automatic merge from submit-queue (batch tested with PRs 51114, 51233, 51024, 51053, 51197)

rbd: Use VolumeHost.GetExec() to execute stuff in volume plugins

**What this PR does / why we need it**:

This PR updates rbd volume plugin to use `VolumeHost.GetExec()` to execute utilities like mkfs and lsblk instead of simple `os/exec`. This prepares the volume plugin to run these utilities in containers instead of running them on the host + makes the volume plugin more independent and less hardcoded.

See proposal in https://github.com/kubernetes/community/pull/589.

Note that this PR does **not** change place where the utilities are executed - `VolumeHost.GetExec()` still leads directly to `os/exec`. It will be changed when the aforementioned proposal is merged and implemented.

@kubernetes/sig-storage-pr-reviews 

**Release note**:
```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2017-08-25 06:22:09 -07:00
committed by GitHub
4 changed files with 55 additions and 44 deletions

View File

@@ -112,7 +112,8 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
}
fdm := NewFakeDiskManager()
defer fdm.Cleanup()
mounter, err := plug.(*rbdPlugin).newMounterInternal(spec, types.UID("poduid"), fdm, &mount.FakeMounter{}, "secrets")
exec := mount.NewFakeExec(nil)
mounter, err := plug.(*rbdPlugin).newMounterInternal(spec, types.UID("poduid"), fdm, &mount.FakeMounter{}, exec, "secrets")
if err != nil {
t.Errorf("Failed to make a new Mounter: %v", err)
}
@@ -137,7 +138,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
}
}
unmounter, err := plug.(*rbdPlugin).newUnmounterInternal("vol1", types.UID("poduid"), fdm, &mount.FakeMounter{})
unmounter, err := plug.(*rbdPlugin).newUnmounterInternal("vol1", types.UID("poduid"), fdm, &mount.FakeMounter{}, exec)
if err != nil {
t.Errorf("Failed to make a new Unmounter: %v", err)
}