From 0d7752b0f501f409aa4fe422b8dbe1cf94048db1 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 6 Feb 2017 09:54:15 -0500 Subject: [PATCH] Update runningOp.Err with State.Unlock error Have the defer'ed State.Unlock call append any error to the RunningOperation.Err field. Local error would be rare and self-correcting, but when the backend.Local is using a remote state the error may require user intervention. --- backend/local/backend_apply.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/local/backend_apply.go b/backend/local/backend_apply.go index 381edfb56..4c0804717 100644 --- a/backend/local/backend_apply.go +++ b/backend/local/backend_apply.go @@ -40,7 +40,14 @@ func (b *Local) opApply( defer func() { if s, ok := opState.(state.Locker); op.LockState && ok { if err := s.Unlock(); err != nil { - log.Printf("[ERROR]: %s", err) + runningOp.Err = multierror.Append(runningOp.Err, + errwrap.Wrapf("Error unlocking state:\n\n"+ + "{{err}}\n\n"+ + "The Terraform operation completed but there was an error unlocking the state.\n"+ + "This may require unlocking the state manually with the `terraform unlock` command\n", + err, + ), + ) } } }()