From fe7635f438c15458a88f95fdb80c0874c93f8f36 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 19 Jan 2021 12:58:00 -0500 Subject: [PATCH] always close all provisioners after each walk This was not done consistently in all cases when the individual provisioner graph nodes were used. Since we removed the graph nodes, the only thing left is to close these at the end of the walk. --- terraform/node_module_expand.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/terraform/node_module_expand.go b/terraform/node_module_expand.go index 2fbd77426..92064f6e4 100644 --- a/terraform/node_module_expand.go +++ b/terraform/node_module_expand.go @@ -140,7 +140,9 @@ func (n *nodeExpandModule) Execute(ctx EvalContext, op walkOperation) (diags tfd // wait on this node. // Besides providing a root node for dependency ordering, nodeCloseModule also // cleans up state after all the module nodes have been evaluated, removing -// empty resources and modules from the state. +// empty resources and modules from the state, and closes a remaining +// provisioner plugins which do not have a lifecycle controlled controlled by +// individual graph nodes. type nodeCloseModule struct { Addr addrs.Module } @@ -174,6 +176,12 @@ func (n *nodeCloseModule) Name() string { } func (n *nodeCloseModule) Execute(ctx EvalContext, op walkOperation) (diags tfdiags.Diagnostics) { + if n.Addr.IsRoot() { + // If this is the root module, we are cleaning up the walk, so close + // any running provisioners + diags = diags.Append(ctx.CloseProvisioners()) + } + switch op { case walkApply, walkDestroy: state := ctx.State().Lock()