Merge pull request #10277 from hashicorp/b-lock
terraform: write lock on post state updates
This commit is contained in:
commit
43869c564d
|
@ -107,9 +107,10 @@ type EvalUpdateStateHook struct{}
|
||||||
func (n *EvalUpdateStateHook) Eval(ctx EvalContext) (interface{}, error) {
|
func (n *EvalUpdateStateHook) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
state, lock := ctx.State()
|
state, lock := ctx.State()
|
||||||
|
|
||||||
// Get a read lock so it doesn't change while we're calling this
|
// Get a full lock. Even calling something like WriteState can modify
|
||||||
lock.RLock()
|
// (prune) the state, so we need the full lock.
|
||||||
defer lock.RUnlock()
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
// Call the hook
|
// Call the hook
|
||||||
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
||||||
|
|
Loading…
Reference in New Issue