Skip to content

Commit

Permalink
Add logging to pinpoint problem, restore crash.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paddycarver committed Jan 25, 2021
1 parent 32303e2 commit 99e4a70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions helper/schema/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions helper/schema/resource_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"errors"
"fmt"
"log"
"reflect"
"strings"
"sync"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 99e4a70

Please sign in to comment.