diff --git a/terraform/debug.go b/terraform/debug.go index c2bd223f0dfa..168bbd55f142 100644 --- a/terraform/debug.go +++ b/terraform/debug.go @@ -224,40 +224,6 @@ func (d *debugInfo) flush() { } } -// WriteGraph takes a DebugGraph and writes both the DebugGraph as a dot file -// in the debug archive, and extracts any logs that the DebugGraph collected -// and writes them to a log file in the archive. -func (d *debugInfo) WriteGraph(name string, g *Graph) error { - if d == nil || g == nil { - return nil - } - d.Lock() - defer d.Unlock() - - // If we crash, the file won't be correctly closed out, but we can rebuild - // the archive if we have to as long as every file has been flushed and - // sync'ed. - defer d.flush() - - dotPath := fmt.Sprintf("%s/graphs/%d-%s-%s.dot", d.name, d.step, d.phase, name) - d.step++ - - dotBytes := g.Dot(nil) - hdr := &tar.Header{ - Name: dotPath, - Mode: 0644, - Size: int64(len(dotBytes)), - } - - err := d.tar.WriteHeader(hdr) - if err != nil { - return err - } - - _, err = d.tar.Write(dotBytes) - return err -} - // WriteFile writes data as a single file to the debug arhive. func (d *debugInfo) WriteFile(name string, data []byte) error { if d == nil { diff --git a/terraform/debug_test.go b/terraform/debug_test.go index 342a86b981d8..927632350c29 100644 --- a/terraform/debug_test.go +++ b/terraform/debug_test.go @@ -16,7 +16,6 @@ func TestDebugInfo_nil(t *testing.T) { var d *debugInfo d.SetPhase("none") - d.WriteGraph("", nil) d.WriteFile("none", nil) d.Close() } @@ -120,9 +119,7 @@ func TestDebug_plan(t *testing.T) { } tr := tar.NewReader(gz) - files := 0 - graphs := 0 - json := 0 + graphLogs := 0 for { hdr, err := tr.Next() if err == io.EOF { @@ -134,28 +131,13 @@ func TestDebug_plan(t *testing.T) { // record any file that contains data if hdr.Size > 0 { - files++ - - // and any dot graph with data - if strings.HasSuffix(hdr.Name, ".dot") { - graphs++ - } - if strings.HasSuffix(hdr.Name, "graph.json") { - json++ + graphLogs++ } } } - if files == 0 { - t.Fatal("no files with data found") - } - - if graphs == 0 { - t.Fatal("no no-empty graphs found") - } - - if json == 0 { + if graphLogs == 0 { t.Fatal("no json graphs") } } diff --git a/terraform/graph.go b/terraform/graph.go index e4ff7a710ba8..60258490dd34 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -246,6 +246,7 @@ func (g *Graph) walk(walker GraphWalker) error { var walkFn dag.WalkFunc walkFn = func(v dag.Vertex) (rerr error) { log.Printf("[DEBUG] vertex '%s.%s': walking", path, dag.VertexName(v)) + g.DebugVisitInfo(v, g.debugName) // If we have a panic wrap GraphWalker and a panic occurs, recover // and call that. We ensure the return value is an error, however, diff --git a/terraform/graph_builder.go b/terraform/graph_builder.go index 9f2d9e97f5d1..2e5ff8e96ef3 100644 --- a/terraform/graph_builder.go +++ b/terraform/graph_builder.go @@ -58,19 +58,10 @@ func (b *BasicGraphBuilder) Build(path []string) (*Graph, error) { } debugOp.End(errMsg) - // always log the graph state to see what transformations may have happened - debugName := "build-" + stepName - if b.Name != "" { - debugName = b.Name + "-" + debugName - } - log.Printf( "[TRACE] Graph after step %T:\n\n%s", step, g.StringWithNodeTypes()) - // TODO: replace entirely with the json logs - dbug.WriteGraph(debugName, g) - if err != nil { return g, err }