resources: Do not panic on autogrouped graph switches

Graph changes from autogrouped -> not autogrouped or vice versa cause a
panic (or I assume a leak) because we compared the auto grouped graph to
the ungrouped one, which would cause an Exit on an unstarted Vertex.
This includes a test that seems to reliably reproduces the issue.
This commit is contained in:
James Shubin
2017-06-07 04:45:25 -04:00
parent 525cd54921
commit 9f5057eac7
6 changed files with 228 additions and 6 deletions

View File

@@ -524,6 +524,8 @@ func (obj *Main) Run() error {
continue
}
//savedGraph := oldGraph.Copy() // save a copy for errors
// TODO: should we call each Res.Setup() here instead?
// add autoedges; modifies the graph only if no error
@@ -537,12 +539,20 @@ func (obj *Main) Run() error {
continue
}
graph.Update(oldGraph) // copy in structure of new graph
// at this point, any time we error after a destructive
// modification of the graph we need to restore the old
// graph that was previously running, eg:
//
// oldGraph = savedGraph.Copy()
//
// which we are (luckily) able to avoid testing for now
resources.AutoGroup(graph.Graph, &resources.NonReachabilityGrouper{}) // run autogroup; modifies the graph
resources.AutoGroup(oldGraph, &resources.NonReachabilityGrouper{}) // run autogroup; modifies the graph
// TODO: do we want to do a transitive reduction?
// FIXME: run a type checker that verifies all the send->recv relationships
graph.Update(oldGraph) // copy in structure of new graph
// Call this here because at this point the graph does
// not know anything about the prometheus instance.
if err := prom.UpdatePgraphStartTime(); err != nil {