Delete pre-provisioned Cinder volume by ID

This commit is contained in:
Jan Safranek 2020-09-23 14:38:45 +02:00
parent 88e3c95d7c
commit ead8707f3a

View File

@ -1191,6 +1191,7 @@ func (c *cinderDriver) CreateVolume(config *testsuites.PerTestConfig, volType te
}
func (v *cinderVolume) DeleteVolume() {
id := v.volumeID
name := v.volumeName
// Try to delete the volume for several seconds - it takes
@ -1199,16 +1200,16 @@ func (v *cinderVolume) DeleteVolume() {
var err error
timeout := time.Second * 120
framework.Logf("Waiting up to %v for removal of cinder volume %s", timeout, name)
framework.Logf("Waiting up to %v for removal of cinder volume %s / %s", timeout, id, name)
for start := time.Now(); time.Since(start) < timeout; time.Sleep(5 * time.Second) {
output, err = exec.Command("cinder", "delete", name).CombinedOutput()
output, err = exec.Command("cinder", "delete", id).CombinedOutput()
if err == nil {
framework.Logf("Cinder volume %s deleted", name)
framework.Logf("Cinder volume %s deleted", id)
return
}
framework.Logf("Failed to delete volume %s: %v", name, err)
framework.Logf("Failed to delete volume %s / %s: %v\n%s", id, name, err, string(output))
}
framework.Logf("Giving up deleting volume %s: %v\n%s", name, err, string(output[:]))
framework.Logf("Giving up deleting volume %s / %s: %v\n%s", id, name, err, string(output[:]))
}
// GCE