From bb137f4bfb1f2355f9f8824c3735a5f2a4c7ed8b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 15 Nov 2016 10:30:50 -0500 Subject: [PATCH] Remove the dot graphs from the debug log, and record the walk visits in the debug information. --- terraform/debug.go | 34 ---------------------------------- terraform/debug_test.go | 24 +++--------------------- terraform/graph.go | 1 + terraform/graph_builder.go | 9 --------- 4 files changed, 4 insertions(+), 64 deletions(-) diff --git a/terraform/debug.go b/terraform/debug.go index c2bd223f0..168bbd55f 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 342a86b98..927632350 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 e4ff7a710..60258490d 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 9f2d9e97f..2e5ff8e96 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 }