mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 00:32:09 -04:00
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.
This commit is contained in:
parent
4a4b837386
commit
0dcb8c02c2
1 changed files with 9 additions and 6 deletions
|
|
@ -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…
Reference in a new issue