From a3c259587f41056f426cfe11728875459370dd3a Mon Sep 17 00:00:00 2001 From: Bruno Moura Date: Sat, 8 Oct 2016 06:49:48 +0100 Subject: [PATCH] Use new error variables when rolling back volume creation to avoid nil reassignment. --- vmdk_plugin/plugin.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/vmdk_plugin/plugin.go b/vmdk_plugin/plugin.go index b0d1f0a64..84b984271 100644 --- a/vmdk_plugin/plugin.go +++ b/vmdk_plugin/plugin.go @@ -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()} } @@ -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()} } @@ -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()} }