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.
This commit is contained in:
James Bardin 2017-02-06 09:54:15 -05:00
parent e92559f518
commit 0d7752b0f5
1 changed files with 8 additions and 1 deletions

View File

@ -40,7 +40,14 @@ func (b *Local) opApply(
defer func() { defer func() {
if s, ok := opState.(state.Locker); op.LockState && ok { if s, ok := opState.(state.Locker); op.LockState && ok {
if err := s.Unlock(); err != nil { 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,
),
)
} }
} }
}() }()