From 337abe3f62f6552448c2b5520e7b7a3be1a719b0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 8 Nov 2016 08:32:36 -0800 Subject: [PATCH] terraform: enable plan shadow graph --- terraform/context.go | 10 ++++++---- terraform/node_resource_plan_instance.go | 5 +++-- terraform/node_resource_plan_orphan.go | 5 +++-- terraform/shadow_resource_provider.go | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index 01857d5c3..bd20864f4 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -558,9 +558,6 @@ func (c *Context) Plan() (*Plan, error) { shadow = nil } - // TODO: remove when we're ready - shadow = nil - // Do the walk walker, err := c.walk(real, shadow, operation) if err != nil { @@ -853,7 +850,12 @@ func (c *Context) walk( // // This must be done BEFORE appending shadowWalkErr since the // shadowWalkErr may include expected errors. - if c.shadowErr != nil && contextFailOnShadowError { + // + // We only do this if we don't have a real error. In the case of + // a real error, we can't guarantee what nodes were and weren't + // traversed in parallel scenarios so we can't guarantee no + // shadow errors. + if c.shadowErr != nil && contextFailOnShadowError && realErr == nil { panic(multierror.Prefix(c.shadowErr, "shadow graph:")) } diff --git a/terraform/node_resource_plan_instance.go b/terraform/node_resource_plan_instance.go index e9e62786e..9dafd22ba 100644 --- a/terraform/node_resource_plan_instance.go +++ b/terraform/node_resource_plan_instance.go @@ -25,8 +25,9 @@ func (n *NodePlannableResourceInstance) EvalTree() EvalNode { // Build the instance info. More of this will be populated during eval info := &InstanceInfo{ - Id: stateId, - Type: addr.Type, + Id: stateId, + Type: addr.Type, + ModulePath: normalizeModulePath(addr.Path), } // Build the resource for eval diff --git a/terraform/node_resource_plan_orphan.go b/terraform/node_resource_plan_orphan.go index e7c749730..90641ca0f 100644 --- a/terraform/node_resource_plan_orphan.go +++ b/terraform/node_resource_plan_orphan.go @@ -26,8 +26,9 @@ func (n *NodePlannableResourceOrphan) EvalTree() EvalNode { // Build the instance info. More of this will be populated during eval info := &InstanceInfo{ - Id: stateId, - Type: addr.Type, + Id: stateId, + Type: addr.Type, + ModulePath: normalizeModulePath(addr.Path), } // Declare a bunch of variables that are used for state during diff --git a/terraform/shadow_resource_provider.go b/terraform/shadow_resource_provider.go index 0c79edf75..ccb095219 100644 --- a/terraform/shadow_resource_provider.go +++ b/terraform/shadow_resource_provider.go @@ -466,7 +466,7 @@ func (p *shadowResourceProviderShadow) ValidateResource(t string, c *ResourceCon p.ErrorLock.Lock() defer p.ErrorLock.Unlock() p.Error = multierror.Append(p.Error, fmt.Errorf( - "Unknown 'ValidateResource' shadow value: %#v", raw)) + "Unknown 'ValidateResource' shadow value for %q: %#v", key, raw)) return nil, nil } @@ -558,7 +558,7 @@ func (p *shadowResourceProviderShadow) Diff( p.ErrorLock.Lock() defer p.ErrorLock.Unlock() p.Error = multierror.Append(p.Error, fmt.Errorf( - "Unknown 'diff' shadow value: %#v", raw)) + "Unknown 'diff' shadow value for %q: %#v", key, raw)) return nil, nil }