Skip to content

Commit

Permalink
trace: add more logging around variable validations (#35539)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcervante authored Aug 6, 2024
1 parent 00c6c6f commit f452b08
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/checks/state_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package checks

import (
"fmt"
"log"

"github.com/hashicorp/terraform/internal/addrs"
)
Expand Down Expand Up @@ -50,6 +51,7 @@ func (c *State) ReportCheckableObjects(configAddr addrs.ConfigCheckable, objectA
checks[checkType] = make([]Status, count)
}

log.Printf("[TRACE] ReportCheckableObjects: %s -> %s", configAddr, objectAddr)
st.objects.Put(objectAddr, checks)
}
}
Expand Down
8 changes: 8 additions & 0 deletions internal/terraform/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func (g *Graph) walk(walker GraphWalker) tfdiags.Diagnostics {
log.Printf("[TRACE] vertex %q: starting visit (%T)", dag.VertexName(v), v)

defer func() {
if r := recover(); r != nil {
// If the walkFn panics, we get confusing logs about how the
// visit was complete. To stop this, we'll catch the panic log
// that the vertex panicked without finishing and re-panic.
log.Printf("[ERROR] vertex %q panicked", dag.VertexName(v))
panic(r) // re-panic
}

if diags.HasErrors() {
for _, diag := range diags {
if diag.Severity() == tfdiags.Error {
Expand Down
1 change: 1 addition & 0 deletions internal/terraform/node_module_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (n *nodeExpandModuleVariable) DynamicExpand(ctx EvalContext) (*Graph, tfdia
forEachModuleInstance(expander, n.Module, false, func(module addrs.ModuleInstance) {
addr := n.Addr.Absolute(module)
if checkableAddrs != nil {
log.Printf("[TRACE] nodeExpandModuleVariable: found checkable object %s", addr)
checkableAddrs.Add(addr)
}

Expand Down

0 comments on commit f452b08

Please sign in to comment.