Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make edge direction flow from client->server. #355

Merged
merged 4 commits into from
Aug 19, 2015
Merged

Conversation

tomwilkie
Copy link
Contributor

So it turns out the layout engine we use is already trying to layout the graph from top-to-bottom: https://github.com/cpettitt/dagre/wiki

This change uses a simple heuristic (client port is the higher port) to orient the edges in the graph such that they flow from client to server.

It somewhat improves the graph layout. Before:

screen shot 2015-08-13 at 15 51 00

After:

screen shot 2015-08-13 at 15 49 45

@peterbourgon
Copy link
Contributor

I don't think you can just swap which end of the connection is used as the key in the adjacency map. We assume that every key in the NodeMetadata map has representation in the adjacency map, too. I'm surprised this doesn't break rendering.

What about just using this change in isolation?

@tomwilkie
Copy link
Contributor Author

That change you refer to is a noop (its the default value). I didn't realise I'd committed it.

@tomwilkie
Copy link
Contributor Author

This next change reverses the assumption that keys in the Adjacency map always exist in the NodeMetadata map. It makes the pseudo node generator take a direction flag, and updates the tests to reflect reality.

One side effect of this PR is previously, when you have a probe running on two different machines, communicating processes on those machines would have two edges in the UI.

A negative side effect is that now, in the details panel, one only sees outgoing connections from the selected node. I intend to address this in this PR, next.

@tomwilkie tomwilkie changed the title Make edge direction flow from client->server. [WIP] Make edge direction flow from client->server. Aug 17, 2015
@tomwilkie tomwilkie self-assigned this Aug 17, 2015
@tomwilkie tomwilkie changed the title [WIP] Make edge direction flow from client->server. Make edge direction flow from client->server. Aug 17, 2015
@tomwilkie tomwilkie removed their assignment Aug 17, 2015
}
}
}
}

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@peterbourgon
Copy link
Contributor

edges only exist in the endpoint topology

This isn't a constraint of the data model. It's just an accident of the implementation. You can't treat it as an invariant and program against it.

But I was thinking — rather than restructuring the adjacency list, why don't you just indicate the client-to-server directionality as a boolean field in the EdgeMetadata?

@tomwilkie
Copy link
Contributor Author

This isn't a constraint of the data model. It's just an accident of the implementation. You can't treat it as an invariant and program against it.

I'm not; I was pointing out that whilst Paul had spotted a bug, the reality was it was never going to be hit. I fixed it anyway.

But I was thinking — rather than restructuring the adjacency list, why don't you just indicate the client-to-server directionality as a boolean field in the EdgeMetadata?

I didn't consider this at the time; what would it buy us?

There is an inherent directionality in the adjacency map; previously it was from local->remote. This approach changed the assumption without changing the datastructure. With this approach there is no duplication of information (previously two edges would have existed between communicating nodes, now only one). Also no UI changes are required, as the UI already assumes the edges are directional, although it was probably just a coincidence.

@peterbourgon
Copy link
Contributor

I'm not; I was pointing out that whilst Paul had spotted a bug, the reality was it was never going to be hit. I fixed it anyway.

Okeedokey.

I didn't consider this at the time; what would it buy us?

We would be able to keep the invariant that NodeMetadatas[id] —implies→ Adjacency[id], which I think is a nice property. But...

There is an inherent directionality in the adjacency map; previously it was from local->remote. This approach changed the assumption without changing the datastructure. With this approach there is no duplication of information (previously two edges would have existed between communicating nodes, now only one). Also no UI changes are required, as the UI already assumes the edges are directional, although it was probably just a coincidence.

I agree with everything here. I'm thinking out loud what "directionality" actually means for us. The edges have both ingress and egress counters so they actually represent both directions of data flow. Therefore, we don't actually have a directed graph, we just have a graph. And the directionality encoded by the adjacency list is kind of meaningless. Well, it has the meaning we assign to it: previously that was (reliably) local-to-remote, now it is (heuristically) client-to-server.

It seems to me that we are trading the property I listed above for more code in rendering and a potentially nicer graph layout. Is that right?

@tomwilkie
Copy link
Contributor Author

The graph is still directed; previous I would say it was undirected, as in most situations having a (src, dst) edge meant you also had a (dst, src) edge. Now you'll only get a single (highest port number, lowest port number) edge - which looks much nicer in the UI, and is factually more correct. The edge represents a tcp connection, not a dataflow. The directionality is super meaningful, but the edgemetadata needs to be updated to deal with it (ingress and egress swapped when appropriate).

I'd phrase this change more as adding more semantics to the topology, which in turns makes the rendering slightly nicer. I don't see how the property of each node metadata key being a valid key in adjacencies was particularly useful - we pretty much only relied on it in one place (the leaf map code). And we were mistakenly relying on both directions of an edge to exist in detailed node rendering, so this change improves that.

@tomwilkie
Copy link
Contributor Author

@peterbourgon I'd like to get this merged today; whats left to do?

@peterbourgon
Copy link
Contributor

Nothing left to do, I was just giving it some brain time to see if there were potentially other problems, but I couldn't come up with any. 👍

@tomwilkie
Copy link
Contributor Author

Cool, no problem. I'll file a follow up ticket to ensure we handle the directionality correcting in EdgeMetadata; currently the only populated field is tcp connection count, which isn't directional, so its fine. But when we get the bandwidth stuff enabled by default, it will bite us.

tomwilkie added a commit that referenced this pull request Aug 19, 2015
Make edge direction flow from client->server.
@tomwilkie tomwilkie merged commit 336ba79 into master Aug 19, 2015
@tomwilkie tomwilkie deleted the directionality branch August 19, 2015 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants