Remove the dot graphs from the debug log,
and record the walk visits in the debug information.
This commit is contained in:
parent
6d30b60144
commit
bb137f4bfb
|
@ -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.
|
// WriteFile writes data as a single file to the debug arhive.
|
||||||
func (d *debugInfo) WriteFile(name string, data []byte) error {
|
func (d *debugInfo) WriteFile(name string, data []byte) error {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
|
|
|
@ -16,7 +16,6 @@ func TestDebugInfo_nil(t *testing.T) {
|
||||||
var d *debugInfo
|
var d *debugInfo
|
||||||
|
|
||||||
d.SetPhase("none")
|
d.SetPhase("none")
|
||||||
d.WriteGraph("", nil)
|
|
||||||
d.WriteFile("none", nil)
|
d.WriteFile("none", nil)
|
||||||
d.Close()
|
d.Close()
|
||||||
}
|
}
|
||||||
|
@ -120,9 +119,7 @@ func TestDebug_plan(t *testing.T) {
|
||||||
}
|
}
|
||||||
tr := tar.NewReader(gz)
|
tr := tar.NewReader(gz)
|
||||||
|
|
||||||
files := 0
|
graphLogs := 0
|
||||||
graphs := 0
|
|
||||||
json := 0
|
|
||||||
for {
|
for {
|
||||||
hdr, err := tr.Next()
|
hdr, err := tr.Next()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -134,28 +131,13 @@ func TestDebug_plan(t *testing.T) {
|
||||||
|
|
||||||
// record any file that contains data
|
// record any file that contains data
|
||||||
if hdr.Size > 0 {
|
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") {
|
if strings.HasSuffix(hdr.Name, "graph.json") {
|
||||||
json++
|
graphLogs++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if files == 0 {
|
if graphLogs == 0 {
|
||||||
t.Fatal("no files with data found")
|
|
||||||
}
|
|
||||||
|
|
||||||
if graphs == 0 {
|
|
||||||
t.Fatal("no no-empty graphs found")
|
|
||||||
}
|
|
||||||
|
|
||||||
if json == 0 {
|
|
||||||
t.Fatal("no json graphs")
|
t.Fatal("no json graphs")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ func (g *Graph) walk(walker GraphWalker) error {
|
||||||
var walkFn dag.WalkFunc
|
var walkFn dag.WalkFunc
|
||||||
walkFn = func(v dag.Vertex) (rerr error) {
|
walkFn = func(v dag.Vertex) (rerr error) {
|
||||||
log.Printf("[DEBUG] vertex '%s.%s': walking", path, dag.VertexName(v))
|
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
|
// If we have a panic wrap GraphWalker and a panic occurs, recover
|
||||||
// and call that. We ensure the return value is an error, however,
|
// and call that. We ensure the return value is an error, however,
|
||||||
|
|
|
@ -58,19 +58,10 @@ func (b *BasicGraphBuilder) Build(path []string) (*Graph, error) {
|
||||||
}
|
}
|
||||||
debugOp.End(errMsg)
|
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(
|
log.Printf(
|
||||||
"[TRACE] Graph after step %T:\n\n%s",
|
"[TRACE] Graph after step %T:\n\n%s",
|
||||||
step, g.StringWithNodeTypes())
|
step, g.StringWithNodeTypes())
|
||||||
|
|
||||||
// TODO: replace entirely with the json logs
|
|
||||||
dbug.WriteGraph(debugName, g)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return g, err
|
return g, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue