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