Repository navigation
clusterer_controller: zero-config HA clusterer control module with automatic sharing tag management via encrypted UDP multicast - #4074
Conversation
|
Thank you very much for the contribution, I really like the idea behind it. I do see though that it is marked as a Draft - is it still work in progress, or has it reached to its final state? Let us know when it is ready to review. |
This comment has been minimized.
This comment has been minimized.
2cf5b36 to
34f1042
Compare
This comment has been minimized.
This comment has been minimized.
f93b82d to
4348580
Compare
This comment has been minimized.
This comment has been minimized.
82e123e to
b7a173e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aad3a24 to
5dc976d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dd0f515 to
22cb916
Compare
f4929be to
71ee0a8
Compare
71ee0a8 to
f2d52f9
Compare
|
A short note on why this update reworks clusterer_controller this much. In my tests the version in this PR could not form a large cluster: 32 nodes started at once on one VM never settled, and even with the master admitting joiners a few at a time, clusterer's ping and link-state layer flooded itself at 64 nodes and the cluster did not form in any of three runs. So controller-managed clusters now get an admission step, a multicast heartbeat in place of clusterer's pings, link-state floods and relaying, and module broadcasts over multicast. With that, 64 nodes started at once form in about two minutes. Clusters without |
f2d52f9 to
7aa859f
Compare
|
I have pushed an update: still the same 6 commits, and only the last one, the module itself, changed. New tests and a second round of measurements found these, now fixed:
Also: a joiner still connecting after 60 s is parked, so the admission queue moves on; a node coming online resyncs every capability, not only the first 16; the paths for members without the probe, admission or maintenance capabilities are gone, as every build of wire version 4 has them; and new network-namespace tests cover a 2-2 split, two members cut from each other, the master killed during an admission, and parking. The description has the new measurements: 64 nodes started at once formed in 10 runs of 10, 128 nodes in about four and a half minutes, and replication at 10% loss and with reordering. |
|
Hi, @Lt-Flash ! Thank you for this amazing work! It's ok to have the tm change inside this PR, no worries! Just to double check, currently we can not run with both Best regards, |
7aa859f to
2f5a2f2
Compare
|
I have pushed an update: still the same 6 commits, and only the last one, the module itself, changed.
New tests: a node whose outgoing multicast is cut, as a member and as the master, and a unit test with three readers, a TCP sender and the broadcast tick running at once. The measurements moved from the description to |
|
Hi @razvancrainea, thank you! Both modules in one instance: right, they cannot run side by side - both register as tm with |
2f5a2f2 to
a54a5f9
Compare
|
I pushed two fixes to the controller. Node ids now stop at 127, so a cluster has at most 127 nodes. Per #4398, the dialog instance id is going into the top byte of The other fix is at startup: the launcher counts the processes it waits for before |
| LM_ERR("no more pkg memory\n"); | ||
| ret=E_OUT_OF_MEM; | ||
| goto error; | ||
| } | ||
| memset(mod,0, sizeof(struct sr_module)); | ||
| mod->path=path; | ||
| mod->path=strcpy((char *)(mod + 1), path); |
There was a problem hiding this comment.
please use memcpy instead of strcpy, as it triggers a lot of errors in coverity and compilers.
There was a problem hiding this comment.
Done, it's a memcpy now, with the length taken once.
25a6efb to
2137aad
Compare
|
I ran a full security and correctness review of the controller and fixed what it found. The most serious issues could be triggered from the network without the cluster password: a joining node accepted packets sealed with a not-yet-set (all-zero) key, a spoofed copy of a joiner's request could make the master send a refusal that shut the joiner down, and the rate limit keyed on spoofable source addresses could silence the master. These are closed: nothing is decrypted before a key exists, nothing answers a packet that failed authentication, a packet's sealed sender must match its source address, and no network input makes a node exit. Members are still trusted with one shared password, but a packet now speaks only for its own address, and node ids, key hand-overs and a joiner's first view come only from the master. The README states what the password does and does not protect. The rest were correctness bugs: a sharing tag moved away without the old holder being told (so a VIP could stay on two nodes), a race between replication and clusterer_reload, broadcasts lost after a node id changed hands, node-removal callbacks run under a lock, a stray trailer field in sync packets, and tm using one node id for all clusters (now get_my_id_in, also added to clusterer's api.h). The cluster parameter parsing is strict and no longer logs the password. |
2137aad to
7c13ae3
Compare
|
I ran a second review over the fixes and pushed what it found: two holes open without the password (replays draining a node's rate budget, junk stalling a cold start), replays of departed nodes and forged incarnations, two NULL dereferences before a node has its identity, TCP replication held before its sender was checked, and two election issues seen while testing. |
7c13ae3 to
b48b822
Compare
|
Rebased onto current master. The only conflicts were in packaging, next to the new NATS packages; I kept both. No code changes. |
b48b822 to
c4e5d3b
Compare
|
I'm still polishing this: I went through the code again for edge cases and failure modes I can foresee and fixed what I found up front. Most of it is behaviour under faults (partitions, restarts, lost or repeated packets) plus some tightening of input checks. It is pushed as one update, rebased onto current master. |
register_module() kept the pointer it was given, and load_module() passes its search buffer, which it cuts back to the bare directory once a module loads - so every module's path read as its mpath directory. The path is now copied, in the same allocation as the module.
'opensips -T <module>' looked the module up by its registered name only, so a module registering under another name than its file's - such as clusterer_controller.so, which registers as clusterer - was reported as not loaded. It now falls back to the module loaded from <module>.so.
…s modules Since f79c98b the %files line of opensips-modules-contrib sat inside the main package's file list in the RPM spec, so every module and README listed after it (acc.so to README.usrloc) went into opensips-modules-contrib instead of opensips. It now follows that list.
tm read clusterer's node id once, at mod_init, and stamped it into the cid Via parameter of every request. When a controller assigns node ids, the id is set after mod_init and can change, so it is read per request instead: no cid until the node has an id, then the live one, and a reply's cid is checked against the live id. It is the id in tm_repl_cluster, through a new get_my_id_in() clusterer API call, since a controller may give a node another id in each cluster; a clusterer that does not provide it (stock clusterer leaves it NULL) keeps get_my_id(). With a static clusterer the id never changes and nothing differs.
…ib module modules/clusterer as it is on master, in modules-contrib/clusterer_controller, built as clusterer_controller.so and otherwise unchanged - it keeps the module name clusterer, so the modules that depend on clusterer, and the configs that set its parameters, work with it unchanged. The next commit reads as a diff against clusterer.
c4e5d3b to
c5fc8ed
Compare
The nodes of a cluster declared with cluster_options use_controller=1 find each other over encrypted IPv4 multicast, elect a master, receive their node ids and BIN addresses from it, and fail the cluster's sharing tags over; every other cluster behaves as with clusterer. A master that most members cannot hear steps down, its sharing tags in backup, until a master hears it again. clusterer's side (per-cluster node ids, controller-managed clusters and sharing tags, BIN messages that cannot override the controller) is in clusterer's files, the controller's own code in cl_ctr_*. Loading clusterer.so beside it is refused. The master admits joiners a few at a time and holds each one CONNECTING, with no role or sharing tag, until its BIN links to every member are up both ways; a joiner stuck there is named with the pairs that are down, and parked after 60 s so that the queue moves on past it. Every member multicasts a heartbeat each second with its links and capability states, so liveness and node events come from heartbeats and links, with no periodic BIN pings, no link-state floods and no routing through other nodes. Module broadcasts go out as one multicast datagram (fragments when larger), numbered per sender, repaired by unicast and ordered with the TCP messages that follow them; what cannot be repaired is reported, and the sender goes down and up to this node's modules, which sync again. Node ids are 1 to 127, so a cluster has at most 127 nodes. Wire version 5. With its unit, network-namespace and real-cluster tests, the packages (opensips-module-contrib-clusterer-controller), the README, an overview diagram, the measurements (doc/benchmarks.md), and libsodium in the CI build dependencies.
c5fc8ed to
6f1de59
Compare
Summary
This PR adds
clusterer_controller, a contrib module that is clusterer with one extra ability: the nodes of a cluster find each other on their own. Give every node the same multicast group, cluster id and password, and they elect a master, which gives each node its node id, tells the others its BIN address and moves the sharing tags when a node goes away. The README has the details and an overview diagram, and doc/benchmarks.md the measurements.Details
use_controller=1); every other cluster behaves exactly as with clusterer.Solution
In a controller-managed cluster:
Compatibility
cidper request instead of once at startup, as the controller assigns it at runtime. With clusterer nothing differs.Closing issues
None.