From 78741ddf909ac607dae41de3c293ecb7901b0eef Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 20 Feb 2017 14:13:50 +0100 Subject: [PATCH] fix cleanup logic if restoring plugin fails The "err" output variable was masked by the "if" statement, so the error was never updated. Signed-off-by: Sebastiaan van Stijn Upstream-commit: 5d25195f29539b3f12fa8dbc802201f93805c1c4 Component: engine --- components/engine/plugin/manager_linux.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/engine/plugin/manager_linux.go b/components/engine/plugin/manager_linux.go index 3c9bad4d65..5c84157ba2 100644 --- a/components/engine/plugin/manager_linux.go +++ b/components/engine/plugin/manager_linux.go @@ -207,9 +207,8 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobs logrus.WithError(rmErr).WithField("dir", backup).Error("error cleaning up after failed upgrade") return } - - if err := os.Rename(backup, orig); err != nil { - err = errors.Wrap(err, "error restoring old plugin root on upgrade failure") + if mvErr := os.Rename(backup, orig); mvErr != nil { + err = errors.Wrap(mvErr, "error restoring old plugin root on upgrade failure") } if rmErr := os.RemoveAll(tmpRootFSDir); rmErr != nil && !os.IsNotExist(rmErr) { logrus.WithError(rmErr).WithField("plugin", p.Name()).Errorf("error cleaning up plugin upgrade dir: %s", tmpRootFSDir)