|
|
|
|
@ -583,18 +583,11 @@ func (m *Meta) backendFromPlan(opts *BackendOpts) (backend.Backend, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if m.stateLock {
|
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), m.stateLockTimeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
// Lock the state if we can
|
|
|
|
|
lockInfo := state.NewLockInfo()
|
|
|
|
|
lockInfo.Operation = "backend from plan"
|
|
|
|
|
|
|
|
|
|
lockID, err := clistate.Lock(lockCtx, realMgr, lockInfo, m.Ui, m.Colorize())
|
|
|
|
|
if err != nil {
|
|
|
|
|
stateLocker := clistate.NewLocker(context.Background(), m.stateLockTimeout, m.Ui, m.Colorize())
|
|
|
|
|
if err := stateLocker.Lock(realMgr, "backend from plan"); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("Error locking state: %s", err)
|
|
|
|
|
}
|
|
|
|
|
defer clistate.Unlock(realMgr, lockID, m.Ui, m.Colorize())
|
|
|
|
|
defer stateLocker.Unlock(nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := realMgr.RefreshState(); err != nil {
|
|
|
|
|
@ -964,18 +957,11 @@ func (m *Meta) backend_C_r_s(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if m.stateLock {
|
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), m.stateLockTimeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
// Lock the state if we can
|
|
|
|
|
lockInfo := state.NewLockInfo()
|
|
|
|
|
lockInfo.Operation = "backend from config"
|
|
|
|
|
|
|
|
|
|
lockID, err := clistate.Lock(lockCtx, sMgr, lockInfo, m.Ui, m.Colorize())
|
|
|
|
|
if err != nil {
|
|
|
|
|
stateLocker := clistate.NewLocker(context.Background(), m.stateLockTimeout, m.Ui, m.Colorize())
|
|
|
|
|
if err := stateLocker.Lock(sMgr, "backend from plan"); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("Error locking state: %s", err)
|
|
|
|
|
}
|
|
|
|
|
defer clistate.Unlock(sMgr, lockID, m.Ui, m.Colorize())
|
|
|
|
|
defer stateLocker.Unlock(nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Store the metadata in our saved state location
|
|
|
|
|
@ -1047,18 +1033,11 @@ func (m *Meta) backend_C_r_S_changed(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if m.stateLock {
|
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), m.stateLockTimeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
// Lock the state if we can
|
|
|
|
|
lockInfo := state.NewLockInfo()
|
|
|
|
|
lockInfo.Operation = "backend from config"
|
|
|
|
|
|
|
|
|
|
lockID, err := clistate.Lock(lockCtx, sMgr, lockInfo, m.Ui, m.Colorize())
|
|
|
|
|
if err != nil {
|
|
|
|
|
stateLocker := clistate.NewLocker(context.Background(), m.stateLockTimeout, m.Ui, m.Colorize())
|
|
|
|
|
if err := stateLocker.Lock(sMgr, "backend from plan"); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("Error locking state: %s", err)
|
|
|
|
|
}
|
|
|
|
|
defer clistate.Unlock(sMgr, lockID, m.Ui, m.Colorize())
|
|
|
|
|
defer stateLocker.Unlock(nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the backend state
|
|
|
|
|
@ -1190,18 +1169,11 @@ func (m *Meta) backend_C_R_S_unchanged(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if m.stateLock {
|
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), m.stateLockTimeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
// Lock the state if we can
|
|
|
|
|
lockInfo := state.NewLockInfo()
|
|
|
|
|
lockInfo.Operation = "backend from config"
|
|
|
|
|
|
|
|
|
|
lockID, err := clistate.Lock(lockCtx, sMgr, lockInfo, m.Ui, m.Colorize())
|
|
|
|
|
if err != nil {
|
|
|
|
|
stateLocker := clistate.NewLocker(context.Background(), m.stateLockTimeout, m.Ui, m.Colorize())
|
|
|
|
|
if err := stateLocker.Lock(sMgr, "backend from plan"); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("Error locking state: %s", err)
|
|
|
|
|
}
|
|
|
|
|
defer clistate.Unlock(sMgr, lockID, m.Ui, m.Colorize())
|
|
|
|
|
defer stateLocker.Unlock(nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unset the remote state
|
|
|
|
|
|