Skip to content

Topology: YAML topology files and gateway priorities#679

Open
thiell wants to merge 4 commits into
clustershell:masterfrom
thiell:feature/gh374-topology-yaml
Open

Topology: YAML topology files and gateway priorities#679
thiell wants to merge 4 commits into
clustershell:masterfrom
thiell:feature/gh374-topology-yaml

Conversation

@thiell

@thiell thiell commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Implements the design discussed in #374 (see the design comment). Closes #374.

YAML topology files

  • New topology.yaml file syntax: routes as a list of gateways/targets objects. Selected by file extension (.yaml/.yml), so --topology works with both syntaxes; INI topology.conf remains fully supported.
  • Unlike INI, the same gateways may appear in several routes: one gateway pool can reach several target groups, with symmetric failback — the core need from the PR Tree: support optional route weights in topology.conf (#374) #678 review.
  • topology.yaml is preferred over topology.conf when both exist at the same config location.
  • TopologyParser becomes a thin facade over per-format backends; graph building and validation are unchanged and format-agnostic. The INI code path is untouched and still covered by the existing tests.
  • PyYAML is imported lazily, only when a YAML topology is loaded (same pattern as YAML group files). Reviewer question (HLD §8): keep it optional like this, or make PyYAML a hard dependency? Note install_requires already pulls PyYAML for pip installs, so this mostly matters for distro packages.

Gateway priorities

  • In YAML, the gateways of a route may be a list of entries with descriptive attributes, in the style of modern YAML tools such as lnetctl: nodes (node set, required), weight (load share among gateways of equal priority, default 1) and priority (failover rank, default 1). A lower number means a higher priority: gateways of a given priority are used only when all gateways with a lower priority number are unreachable:
routes:
  - gateways:
      - nodes: gw1
      - nodes: gw2
        priority: 2         # gw1 default, gw2 failover
    targets:  rio[100-199]
  - gateways:
      - nodes: gw2
      - nodes: gw1
        priority: 2         # gw2 default, gw1 failover
    targets:  rio[200-299]
  • A plain list of node sets (gateways: [gw1, gw2]) is a load-shared pool, equivalent to gateways: gw[1-2] — failover is always explicit with priority, and the entry form keeps the schema extensible for future per-gateway attributes.
  • Gateways of equal priority share the load with least-connections as today, weighted by weight (integers >= 1). Weight 0 is rejected: a standby gateway is a higher priority number, so there is only one mechanism.
  • Priorities apply to all traffic routed through the pool, including targets deeper in the tree.
  • Resolved priorities ride the pickled TopologyTree; trees from older versions are still accepted, and the wire protocol is unchanged.

Docs and tests

  • config.rst/clush.rst document the YAML syntax, quoting rules (@group values must be quoted), precedence and priorities — including explicitly that a lower priority number wins; conf/topology.yaml.example added.
  • New tests/TreeRouterTest.py covers gateway selection: priority order, failover, mutual failback, weighted distribution, pool equivalence of plain lists, multi-level trees, pickled-tree round-trip, pre-1.11 tree compatibility. YAML parser tests added to TreeTopologyTest, including INI/YAML tree equivalence.

Supersedes PR #678 (now a draft): the INI [weights] section is not kept, and its weighted least-connections selection is reused as the load-sharing policy among gateways of equal priority.

thiell added 2 commits July 18, 2026 08:39
Turn TopologyParser into a thin facade over an internal ConfigParser
and an intermediate route list, so that a second configuration format
can be added. No behavior change.

Signed-off-by: Stephane Thiell <stephane@thiell.com>
Add a YAML topology file syntax, selected by .yaml/.yml file
extension. Routes are a list of gateways/targets objects and the
same gateways may appear in several routes. topology.yaml is
preferred over topology.conf at each config location. INI stays
fully supported. PyYAML is imported lazily, as for YAML group files.

Signed-off-by: Stephane Thiell <stephane@thiell.com>
thiell added 2 commits July 23, 2026 19:56
In a YAML topology file, the gateways of a route may be a list of
entries with nodes, weight and priority attributes. A lower number
means a higher priority: gateways of a given priority are used only
when all gateways with a lower priority number are unreachable.
Gateways of equal priority share the load using weighted
least-connections. Resolved priorities ride the propagation tree
sent to gateways; older trees without priorities are still accepted.

Signed-off-by: Stephane Thiell <stephane@thiell.com>
Document the topology.yaml syntax, gateway priorities and discovery
precedence in config.rst and clush.rst. INI topology.conf remains
documented as fully supported.

Signed-off-by: Stephane Thiell <stephane@thiell.com>
@thiell
thiell force-pushed the feature/gh374-topology-yaml branch from 63b60a9 to a2755a8 Compare July 24, 2026 03:03
@thiell thiell changed the title Topology: YAML topology files and ordered gateway tiers Topology: YAML topology files and gateway priorities Jul 24, 2026
@thiell

thiell commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Renamed tier to priority as agreed in #374; docs now state explicitly that a lower number means a higher priority.

@thiell thiell self-assigned this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway: add hop/weight parameter to routes

1 participant