Skip to main content

Module fleet_sync

Module fleet_sync 

Source
Expand description

Keeps the fleetโ€™s Global Memory in step (task #12439, section 4.6): the sending half of memory.global.put, .remove and .list.

One loop, no change observer: every few seconds this machine fingerprints what it holds for the fleet (backend::memory::fleet::fingerprint) and, for each LAN peer whose last sync had another fingerprint (or that has not been synced since it appeared, which is how a machine that was offline catches up), lists what the peer holds and sends what it lacks or has older. Each side runs the same loop, so what the peer holds newer comes back on its own turn. A peer that is not reachable, is not proven, or does not have the ops is left alone until a retry time. Nothing is sent when nothing changed, so the audit trails only carry real work. What each peer answered (applied, or kept what it had and why) is kept in status for the Memory list, so the writer can see which entries did not arrive.

Modulesยง

status ๐Ÿ”’
What the fleet Global Memory sync did, per peer, for the Memory list to show: when each peer was last synced, how many entries went, why it could not be (a refused list, an unreachable machine), and which entries the peer answered but did not apply (an ownerโ€™s machine entry, say). The writer reads this instead of finding out from the peerโ€™s stewards that an entry never arrived.

Structsยง

Peer ๐Ÿ”’
One machine to sync with: a key that tells it from the others, and the host the send takes.
Synced ๐Ÿ”’
What the last sync of one peer saw.

Enumsยง

Answered ๐Ÿ”’
How the peer answered one entry: Applied when it changed what it holds, Skipped(why) when it answered and kept what it had for a reason the writer should hear about, Nothing when there was nothing to do (it already holds it, or holds a newer one, which comes back on its own turn).

Constantsยง

REASON ๐Ÿ”’
RESYNC ๐Ÿ”’
A peer is synced again after this long even if nothing here changed, to heal a lost push.
RETRY ๐Ÿ”’
A peer that failed is left alone this long.
SIGNING_SLACK ๐Ÿ”’
The signed form of params is a little longer than their JSON text.
TICK ๐Ÿ”’
How often this machine checks whether it has something new for its peers.

Functionsยง

answered ๐Ÿ”’
blocking ๐Ÿ”’
install ๐Ÿ”’
Start the loop. Does nothing while remote operations are off.
peer_key ๐Ÿ”’
What tells one peer from another in the syncโ€™s bookkeeping. Not the discoveryโ€™s instance_id: on a stable build it is the version (v0.60.35), the same on every machine running it, so peers that share a version shared one record, and a pass that had synced one counted the others as synced too (only one peer in ten minutes got anything). The install and the channel are the machineโ€™s own; an install that does not announce an id is told apart by its name, channel and address.
peers ๐Ÿ”’
signer ๐Ÿ”’
An agent of this machine to sign with: the requests are slug@machine on both audit trails.
sync_once ๐Ÿ”’
sync_peer ๐Ÿ”’
List what peer holds and send it what it lacks. Returns how many entries and removals the peer applied, and which ones it answered but did not apply (an ownerโ€™s machine entry, say) with why. An entry the peer takes badly (one too big to send, say) is skipped and counted, not retried now; the peer is retried later only when the list itself failed or a send could not reach it.
sync_peers ๐Ÿ”’
Sync every peer that is due. Separate from sync_once so a test can give it a fake machine.
sync_peers_with ๐Ÿ”’
sync_peers, with the status it reports to given, so a test reads its own.
why_not ๐Ÿ”’