From 606207e79f3036367534eb43d21fe17fadc16a49 Mon Sep 17 00:00:00 2001 From: Paddy Carver Date: Mon, 25 Jan 2021 10:23:37 -0800 Subject: [PATCH] Add logging to pinpoint problem, restore crash. Add logging that will catch the bug red-handed, hopefully, or at least give us more details if our understanding of the bug is off. Also, restore the crash behavior so we can see where it fits in with the logs. --- helper/schema/grpc_provider.go | 5 +---- helper/schema/resource_diff.go | 3 +++ helper/schema/schema.go | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/helper/schema/grpc_provider.go b/helper/schema/grpc_provider.go index 9043cce94fd..cc4a9ec4452 100644 --- a/helper/schema/grpc_provider.go +++ b/helper/schema/grpc_provider.go @@ -796,10 +796,7 @@ func (s *GRPCProviderServer) PlanResourceChange(ctx context.Context, req *tfprot newExtra := map[string]interface{}{} for k, v := range diff.Attributes { - if v == nil { - log.Printf("[WARN] Field %q was null, not modifying its NewExtra", k) - continue - } + log.Printf("[TRACE] tpg-7934: copying over attribute %q", k) if v.NewExtra != nil { newExtra[k] = v.NewExtra } diff --git a/helper/schema/resource_diff.go b/helper/schema/resource_diff.go index 984929df7b5..521c58768de 100644 --- a/helper/schema/resource_diff.go +++ b/helper/schema/resource_diff.go @@ -3,6 +3,7 @@ package schema import ( "errors" "fmt" + "log" "reflect" "strings" "sync" @@ -461,9 +462,11 @@ func (d *ResourceDiff) getChange(key string) (getResult, getResult, bool) { var new getResult for p := range d.updatedKeys { if childAddrOf(key, p) { + log.Printf("[TRACE] tpg-7934: key %q is child of parent %q, counts as computed", key, p) new = d.getExact(strings.Split(key, "."), "newDiff") return old, new, true } + log.Printf("[TRACE] tpg-7934: key %q is not child of parent %q, does not count as computed", key, p) } new = d.get(strings.Split(key, "."), "newDiff") return old, new, false diff --git a/helper/schema/schema.go b/helper/schema/schema.go index f3df1bb4eea..2254cac4a69 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -360,6 +360,7 @@ func (s *Schema) ZeroValue() interface{} { func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *terraform.ResourceAttrDiff { if d == nil { + log.Println("[TRACE] tpg-7934: returning nil from finalizeDiff because nil was passed in") return d } @@ -408,6 +409,7 @@ func (s *Schema) finalizeDiff(d *terraform.ResourceAttrDiff, customized bool) *t if d.Old != "" && d.New == "" { // This is a computed value with an old value set already, // just let it go. + log.Println("[TRACE] tpg-7934: returning nil from finalizeDiff because customized") return nil } } @@ -1383,6 +1385,7 @@ func (m schemaMap) diffString( return nil } + log.Printf("[TRACE] tpg-7934: setting attribute %q", k) diff.Attributes[k] = schema.finalizeDiff( &terraform.ResourceAttrDiff{ Old: os,