hcl2template: don't use Walk for walking on DAG

Walk uses a reverse topological order to walk on the graph, doing that
visit concurrently if possible.

This is nice as we can speed-up execution of datasources and locals,
however since the `Variables` map stored in the config, and the
production of the context for it, are not meant to be used concurrently,
this means that we end-up in cases where Packer crashes because of
concurrent accesses to that map.

So until we can change this behaviour, we will fallback to using the
sequential visit algorithm for those vertexes, therefore limiting the
risk of those conflicts.
pull/13197/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent 4a4b837386
commit 0dcb8c02c2

@ -461,11 +461,6 @@ func (cfg *PackerConfig) evaluateBuildPrereqs(skipDatasources bool) hcl.Diagnost
})
}
// ("unsupported node of type %q")
if diags.HasErrors() {
return diags
}
return nil
}
@ -473,7 +468,15 @@ func (cfg *PackerConfig) evaluateBuildPrereqs(skipDatasources bool) hcl.Diagnost
cfg.LocalVariables = Variables{}
}
return diags.Extend(graph.Walk(walkFunc))
for _, vtx := range graph.ReverseTopologicalOrder() {
vtxDiags := walkFunc(vtx)
if vtxDiags.HasErrors() {
diags = diags.Extend(vtxDiags)
return diags
}
}
return nil
}
func (cfg *PackerConfig) Initialize(opts packer.InitializeOptions) hcl.Diagnostics {

Loading…
Cancel
Save