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

BT order reversed in single subgraph #1678

Open
jthomerson opened this issue Sep 12, 2020 · 2 comments
Open

BT order reversed in single subgraph #1678

jthomerson opened this issue Sep 12, 2020 · 2 comments
Labels
Graph: Flow Internals: Parser Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@jthomerson
Copy link

Describe the bug
I'm building an open source tool that helps manage and visualize dependencies between microservices. I'm using a flowchart to represent the dependencies between services, and services are in systems. Each system is a subgraph. There's also a special subgraph called "root" that has root dependencies that must be deployed before any other service.

When I use flowchart BT to get the root dependencies at the top of the graph (all dependencies point "up" to root), everything works great, except the dependencies within the root subgraph go top-to-bottom.

To Reproduce

Use this graph:

flowchart BT
   subgraph root
   root-resources[root-resources]
   envgroup-resources[envgroup-resources]
   end

   subgraph core
   root-resources
   envgroup-resources
   content-storage([content-storage])
   content-storage-backup([content-storage-backup])
   primary-domain-routing([primary-domain-routing])
   config-storage([config-storage])
   versioned-config([versioned-config])
   end

   subgraph cms
   discovery-api([discovery-api])
   downloads-api([downloads-api])
   management-api([management-api])
   end

   subgraph search
   search-cluster([search-cluster])
   search-api([search-api])
   search-doc-storage([search-doc-storage])
   end

   subgraph edge
   alb-vpc([alb-vpc])
   load-balancer([load-balancer])
   cdn([cdn])
   end

   envgroup-resources --> root-resources
   content-storage-backup --> content-storage
   versioned-config --> config-storage
   discovery-api --> content-storage
   downloads-api --> content-storage
   management-api --> content-storage
   search-api --> search-cluster
   load-balancer --> discovery-api
   load-balancer --> downloads-api
   load-balancer --> management-api
   load-balancer --> search-api
   load-balancer --> alb-vpc
   cdn --> load-balancer
   core -..-> root
   cms -..-> root
   search -..-> root
   edge -..-> root
Loading

This is how it renders:

mermaid-diagram-20200912033538

Expected behavior
I would expect root-resources to be on the top since this is a BT chart. For example, I would expect it to look like this:

flowchart BT
   root-resources[root-resources]
   envgroup-resources[envgroup-resources]
   envgroup-resources --> root-resources

mermaid-diagram-20200912033702

Notably, a tweak to make each subgraph depend on the last dependency in the root subgraph (rather than depending on the root subgraph itself) fixes the problem. Here's the adjusted Mermaid:

flowchart BT
   subgraph root
   core:root-resources[core:root-resources]
   core:envgroup-resources[core:envgroup-resources]
   end

   subgraph core
   core:root-resources
   core:envgroup-resources
   core:content-storage([core:content-storage])
   core:content-storage-backup([core:content-storage-backup])
   core:primary-domain-routing([core:primary-domain-routing])
   core:config-storage([core:config-storage])
   core:versioned-config([core:versioned-config])
   end

   subgraph search
   search:search-doc-storage([search:search-doc-storage])
   search:search-cluster([search:search-cluster])
   search:search-api([search:search-api])
   end

   subgraph cms
   cms:discovery-api([cms:discovery-api])
   cms:downloads-api([cms:downloads-api])
   cms:management-api([cms:management-api])
   end

   subgraph edge
   edge:alb-vpc([edge:alb-vpc])
   edge:load-balancer([edge:load-balancer])
   edge:cdn([edge:cdn])
   end

   core:envgroup-resources --> core:root-resources
   core:content-storage-backup --> core:content-storage
   core:versioned-config --> core:config-storage
   cms:discovery-api --> core:content-storage
   cms:downloads-api --> core:content-storage
   cms:management-api --> core:content-storage
   search:search-api --> search:search-cluster
   edge:load-balancer --> cms:discovery-api
   edge:load-balancer --> cms:downloads-api
   edge:load-balancer --> cms:management-api
   edge:load-balancer --> search:search-api
   edge:load-balancer --> edge:alb-vpc
   edge:cdn --> edge:load-balancer
   core -..-> core:envgroup-resources
   search -..-> core:envgroup-resources
   cms -..-> core:envgroup-resources
   edge -..-> core:envgroup-resources
Loading

Those last four lines are the ones that changed. Here's the result. It gets the dependency direction correct, but makes the root subgraph look awful because the box becomes very large. That's why I'd rather just link the subgraphs rather than items in each subgraph.

mermaid-diagram-20200912034215

Thanks for the awesome library! Let me know if more info would be helpful. I used the Mermaid Live Editor to produce these diagrams, at version 8.8.0.

@jthomerson jthomerson added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Sep 12, 2020
@jthomerson
Copy link
Author

This issue might have some similarity to the feature request in #550. I think the bug could be fixed without implementing the feature, but the feature could also give folks more control and eliminate the bug - because I could specify BT in the top "root" graph, and LR or RL or BT etc in each subgraph.

@knsv knsv mentioned this issue May 18, 2021
3 tasks
@jpl-jengelke
Copy link

jpl-jengelke commented Jul 13, 2022

Related? #815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graph: Flow Internals: Parser Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

3 participants