terraform: shadow graph runs in sequence after the real graph
This commit is contained in:
parent
a355d4ad55
commit
61c789aace
|
@ -613,27 +613,12 @@ func (c *Context) walk(
|
||||||
|
|
||||||
// If we have a shadow graph, walk that as well
|
// If we have a shadow graph, walk that as well
|
||||||
var shadowCtx *Context
|
var shadowCtx *Context
|
||||||
var shadowCh chan error
|
|
||||||
var shadowCloser Shadow
|
var shadowCloser Shadow
|
||||||
if shadow != nil {
|
if shadow != nil {
|
||||||
// Build the shadow context. In the process, override the real context
|
// Build the shadow context. In the process, override the real context
|
||||||
// with the one that is wrapped so that the shadow context can verify
|
// with the one that is wrapped so that the shadow context can verify
|
||||||
// the results of the real.
|
// the results of the real.
|
||||||
realCtx, shadowCtx, shadowCloser = newShadowContext(c)
|
realCtx, shadowCtx, shadowCloser = newShadowContext(c)
|
||||||
|
|
||||||
// Build the graph walker for the shadow.
|
|
||||||
shadowWalker := &ContextGraphWalker{
|
|
||||||
Context: shadowCtx,
|
|
||||||
Operation: operation,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kick off the shadow walk. This will block on any operations
|
|
||||||
// on the real walk so it is fine to start first.
|
|
||||||
shadowCh = make(chan error)
|
|
||||||
go func() {
|
|
||||||
log.Printf("[INFO] Starting shadow graph walk: %s", operation.String())
|
|
||||||
shadowCh <- shadow.Walk(shadowWalker)
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the real graph walker
|
// Build the real graph walker
|
||||||
|
@ -645,6 +630,20 @@ func (c *Context) walk(
|
||||||
|
|
||||||
// If we have a shadow graph, wait for that to complete
|
// If we have a shadow graph, wait for that to complete
|
||||||
if shadowCloser != nil {
|
if shadowCloser != nil {
|
||||||
|
// Build the graph walker for the shadow.
|
||||||
|
shadowWalker := &ContextGraphWalker{
|
||||||
|
Context: shadowCtx,
|
||||||
|
Operation: operation,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick off the shadow walk. This will block on any operations
|
||||||
|
// on the real walk so it is fine to start first.
|
||||||
|
shadowCh := make(chan error)
|
||||||
|
go func() {
|
||||||
|
log.Printf("[INFO] Starting shadow graph walk: %s", operation.String())
|
||||||
|
shadowCh <- shadow.Walk(shadowWalker)
|
||||||
|
}()
|
||||||
|
|
||||||
// Notify the shadow that we're done
|
// Notify the shadow that we're done
|
||||||
if err := shadowCloser.CloseShadow(); err != nil {
|
if err := shadowCloser.CloseShadow(); err != nil {
|
||||||
c.shadowErr = multierror.Append(c.shadowErr, err)
|
c.shadowErr = multierror.Append(c.shadowErr, err)
|
||||||
|
|
Loading…
Reference in New Issue