Repository navigation
The servers of a cluster of several can be upgraded one at a time, the cluster CA rotated with several servers, and the leases of a steady cluster no longer make most of the Raft log (docs/ha.md).
Upgrading from 2.3.1 or 2.3.0
A cluster of one migrates its store on its first start, from schema version 18 to 19, which adds three columns; a 2.3.0 binary cannot open it after that, so take a backup with hivemind backup first. A cluster of several is upgraded one server at a time, followers first and the leader last, while it takes writes: a server of several keeps its store at 18 when it starts, and the leader moves every server's store to 19 through the log once every server runs 2.4.0. Until then each server can go back to 2.3.0. Join no server during the upgrade. See docs/upgrading.md.
Added
- Rolling upgrades of the servers (docs/ha.md). A log entry carries its format and the schema version of the store it was recorded at, the cluster's, not the build's: a 2.4.0 leader of a cluster at 18 records at 18, which 2.3.0 applies, and a 2.4.0 server applies a 2.3.0 leader's entries. Each build runs a range of schema versions, 18 to 19 for 2.4.0, and a server of several opens its store at the version it has, refusing one older than its range as two releases apart. The step of the schema is a log entry of its own format, which the leader appends once every server of the Raft configuration runs the next version; it asks each one every 10 s over the server port, and a 2.3.0 server's refusal of that request reads as a build that runs 18 alone. A server join takes a build that runs the cluster's version.
hivemind serversshows each server's release, and the store's schema version with what its next step waits for.- The CA rotation with several servers (docs/ha.md). The leader records the new CA in the rotation's record, its key sealed with AES-256-GCM under a key derived (HKDF-SHA256) from the current CA's private key, which every server has in
ca.key. Every server follows the record at its start and after each entry from another server: it writes its ownca-next.keyandca-next.crt, takes each phase, moves its own certificate with the listener CA before the CAs it accepts narrow, and does its own file step at the end, which records the kept CA's fingerprint, so a server that missed the end renames its files by it. A server's own node now says which CAs its server accepts, so the listener's move andfinishwait for every server's node, a stopped server's too.hivemind ca statuslists each server's CA files. Schema version 19 adds the new CA to the rotation's record and the CA's fingerprint to the cluster record. scripts/integration-haops.sh, run byscripts/integration-ha.sh(CI'shastep): three servers and two workers built from the 2.3.1 tag, upgraded one server at a time to this build under writes through every server and requests through the workers' routers, with the Raft entries a minute measured before and after; then a CA rotation of the upgraded cluster with a server stopped through part of it.scripts/raft-rate.shtakesWORKERS.
Changed
- On the leader of a cluster of several, a lease renewal, or a report that changes nothing but the time, from a node whose stored lease is no older than 9 s writes nothing: the leader keeps it in memory and writes what it keeps for every node in one entry every 4 s, and before it hands the leadership on (docs/ha.md). A live node's stored lease is never older than 13 s, inside the 15 s lease, and a node that stops is lost 15 s after its last renewal, as before. A cluster of one writes every renewal, as before. Three servers and ten nodes, steady, appended 420 entries a minute on 2.3.0 and 15 on 2.4.0 (docs/ha.md).
- An agent skips its lease renewal of every 5 s when a report went through within the last 5 s, after its first renewal.
hivemind ca rotate startwith several servers is refused only while the store is below schema version 19, and while a server is a non-voter catching up. In a cluster of one at 19,startrecords the rotation before it writes the new CA's files, which a server that stops in between writes at its next start.
Fixed
What the fifth acceptance run found that 2.3.0 left:
- A join with a token of the other kind, a worker's token for
join --role serveror a server's for a worker's join, was refused asthe join token is invalid, used or expired, the message of an unknown or expired token, so neither the user nor the operator could tell the mistake. It now says which kind the token is and which to use, as inthe join token is a worker's: a server joins with a token from hivemind join-token --role server, and the token stays unused. Every other refused token keeps the one message. hivemind join-token --role serveragainst a 2.2.0 server printederror: invalid JSON: json: unknown field "server", the server's refusal of a field it does not know. It now saysthe server runs v2.2.0, which is older than 2.3.0 and cannot have other servers; upgrade it first.hivemind serversexited 0 when no server led, with a line after the table that said so, so a script could not tell. It now prints the list, thenerror: no leader, as <server> sees it: ..., and exits with status 1; with--jsonit prints the JSON, whoseleaderis empty, and exits with status 1.- Given one server URL that answered
no leader: ..., as with one of two servers stopped, every CLI call asked it again for 3 s before it printed that answer. A server's no-leader503now says how long it has known no leader (Hivemind-No-Leader-For, in seconds), and given one server that says 3 s or more the CLI prints the answer at once. One that says less, as during an election, one that knows a leader it could not reach, as while the leadership passes on, and a 2.3 server, which does not say, are still tried again for up to 3 s, and so is a list of servers. - On a server that joined a cluster, a CLI command without a token said
no API token: pass --token, set HIVEMIND_TOKEN, or run hivemind init on this machine, andinitis refused there. It now says that the data directory holds a server that joined, which has noadmin.token, and to give the cluster's admin token withHIVEMIND_TOKENor--token. hivemind backupsaid the backup held the admin token just after listing its files withoutadmin.token, as every backup of a server that joined, andbackup --apiwhile such a server leads, are. The note names the token only when the archive holds it, and the help says when it does.- A drain of a lost node with nothing left to move did not end until its deadline, 10 minutes by default: it waited for the node's agent to remove the containers the node last reported, and a lost node reports nothing. That was the drain the docs gave after
server removeof a server that was down. A lost node's drain is now done once only replicas with a volume are left on it, at once for a node that was lost before the drain, andnode drainsays that the containers the node last reported may still run on its machine until it comes back. serveon a data directory without a cluster made a store there before it saidno cluster in /var/lib/hivemind: run hivemind init first, andjointhen refused the directory as one that held a cluster. With a server join stopped early and the unit'sserveafter it, as in the docs, the machine could not join again until the directory was emptied.servenow makes no store where there is none, and says to runinitorjoin; a store without a cluster, as an earlierserveleft, gets the advice to runinitfor a new cluster or to empty the directory and join.hivemind join's one-line help,Join a cluster as a worker, then run its agent, and the first line of its help left out--role server. Both name it now.
Found while 2.4.0 was tested:
- During a CA rotation, one request that a node sent before it took the new CA, and that came after a later one, made the node count as not trusting the new CA, and
ca rotate renewwaited for it. A long poll that fails over to another server, as when the node's server stops, carries the headers it started with. A node that trusts the new CA now counts as no longer trusting it only after a second request without it, 2 s or more after the first, with none that lists it in between. A node that no longer trusts it still counts within about 5 s. The server logs it when that happens. - A server that stopped while it wrote its copy of the new CA, between the two files or before they were synced, would not start again:
restore the data directory from a backup. It now writes the pair again from the rotation's record. A server that stopped between the two renames at a rotation's end, with the new key already inca.key, would not start once the rotation had ended. It now does the second rename. - On an h2c route, a client on HTTP/1.1 could get a cut reply (
unexpected EOF) when the replica answered before the router had sent it the whole request body. Go's HTTP/1 server reads the rest of a request body away once the reply starts, and the router's copy of the body to the replica then failed. A stream whose client was still sending, as a bidirectional one, did not get its reply at all. The router now asks for full duplex on HTTP/1 requests to h2c routes; HTTP/2 clients were not affected. - The iptables example in docs/security.md dropped traffic to ports 32768 to 60999, the kernel's ephemeral range, but routed containers publish on 30000 to 32767, so the rule did not cover them. The example now names 30000:32767, as docs/routing.md does. If you copied the old rule, replace it.
- The leader could write the step to the next schema version just as a 2.3 server joined, so that the new server was added and then refused the step. The step and server joins are now serialised, and a join checks the store's schema version again before it adds the server.