Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Use new error variables when rolling back volume creation to avoid ni…
Browse files Browse the repository at this point in the history
…l reassignment.
  • Loading branch information
brunotm committed Oct 8, 2016
1 parent 8d42baa commit a3c2595
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions vmdk_plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ func (d *vmdkDriver) Create(r volume.Request) volume.Response {
if err != nil {
log.WithFields(log.Fields{"name": r.Name,
"error": err}).Error("Attach volume failed, removing the volume ")
err = d.ops.Remove(r.Name, nil)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Remove volume failed ")
return volume.Response{Err: err.Error()}
errRm := d.ops.Remove(r.Name, nil)
if errRm != nil {
log.WithFields(log.Fields{"name": r.Name, "error": errRm}).Error("Remove volume failed ")
return volume.Response{Err: errRm.Error()}
}
return volume.Response{Err: err.Error()}
}
Expand All @@ -261,15 +261,15 @@ func (d *vmdkDriver) Create(r volume.Request) volume.Response {
if err != nil {
log.WithFields(log.Fields{"name": r.Name,
"error": err}).Error("Could not find attached device, removing the volume ")
err = d.ops.Detach(r.Name, nil)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Detach volume failed ")
return volume.Response{Err: err.Error()}
errDetach := d.ops.Detach(r.Name, nil)
if errDetach != nil {
log.WithFields(log.Fields{"name": r.Name, "error": errDetach}).Error("Detach volume failed ")
return volume.Response{Err: errDetach.Error()}
}
err = d.ops.Remove(r.Name, nil)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Remove volume failed ")
return volume.Response{Err: err.Error()}
errRm := d.ops.Remove(r.Name, nil)
if errRm != nil {
log.WithFields(log.Fields{"name": r.Name, "error": errRm}).Error("Remove volume failed ")
return volume.Response{Err: errRm.Error()}
}
return volume.Response{Err: err.Error()}
}
Expand All @@ -278,15 +278,15 @@ func (d *vmdkDriver) Create(r volume.Request) volume.Response {
if err != nil {
log.WithFields(log.Fields{"name": r.Name,
"error": err}).Error("Create filesystem failed, removing the volume ")
err = d.ops.Detach(r.Name, nil)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Detach volume failed ")
return volume.Response{Err: err.Error()}
errDetach := d.ops.Detach(r.Name, nil)
if errDetach != nil {
log.WithFields(log.Fields{"name": r.Name, "error": errDetach}).Error("Detach volume failed ")
return volume.Response{Err: errDetach.Error()}
}
err = d.ops.Remove(r.Name, nil)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Remove volume failed ")
return volume.Response{Err: err.Error()}
errRm := d.ops.Remove(r.Name, nil)
if errRm != nil {
log.WithFields(log.Fields{"name": r.Name, "error": errRm}).Error("Remove volume failed ")
return volume.Response{Err: errRm.Error()}
}
return volume.Response{Err: err.Error()}
}
Expand Down

0 comments on commit a3c2595

Please # to comment.