Skip to content

v6.9.0

Choose a tag to compare

@n36l3c7 n36l3c7 released this 21 Nov 19:09
· 8 commits to main since this release
3c27dd4

It starts again in minutes: the server can go back to a moment, a second host takes its place by one command, and a restart loses no work and does nothing twice.

The archive of the database turns on by itself at the upgrade and uses disk on a new volume. Read Upgrading.

What changed

  • Recovery to a moment: PostgreSQL's log is archived continuously and a base backup is taken every day. deploy/restore.sh --to "<time>" brings the server back to any moment of the last days, on the same host or a new one, and keeps the replaced database aside.
  • The archive is proven every day by replaying it into a scratch server.
  • Copies off the host: the log, the base backups and the files of the store go sealed to the second host over SFTP.
  • A standby host: deploy/standby.sh init | status | promote | rejoin. No port is opened between the two hosts. A server that was replaced refuses to serve, and the files the hosts leave for each other are signed.
  • Deleted files are kept for as long as a recovery could need them.
  • Work in progress survives a restart of the server, of a worker or of the database: playbook steps go on, and analyses, scans, captures and mailboxes start again by themselves.
  • A step that was changing something in another system is never repeated by guessing: the run waits as interrupted and a person says It happened, go on, It did not, do it again or Stop the run. The HTTP request node has a Safe to repeat switch.
  • Work that is interrupted three times is set aside with that reason.
  • The stack stops politely, in at most a minute; an upload cut by a restart stays in the transfers tray with Try again.
  • Every shipped connector command that changes another system says whether it may be repeated: 51 commands in eight packs now say idempotent: false, and those packs are a patch version later.
  • Health gains the groups Recovery and Work in progress, with metrics.

Upgrading

git pull
podman compose up -d --build
  • Migrations 0052_recovery and 0053_jobs run after the snapshot and the rehearsal. Every image is rebuilt, and PostgreSQL restarts once with its new settings.
  • The archive turns on by itself: a service recovery, the volumes wal-archive and db-socket, a base backup at once and one a day, a recovery test a day. NIK_WAL_ARCHIVE=off turns it off.
  • Work that was in flight: steps that may be repeated are done again; the others wait as interrupted — look at Automations → Runs afterwards. A file that was being parsed after its upload ends in error and is uploaded again.
  • The copies off the host need what the backups already have: a passphrase and a destination. They go under recovery/ there.
  • A standby is set up by the steps of A standby host in the deployment guide.
  • Update the packs of AbuseIPDB, GreyNoise, MalwareBazaar, OTX, Shodan, urlhaus, urlscan and VirusTotal from Settings → Content packs.
  • An install without containers changes its unit: gunicorn runs with -k app.serving.Worker.

What a failure costs

Failure Lost Back in (measured on small data)
The host dies, with a standby at most five minutes by default under a minute by standby.sh promote
The host dies, copies but no standby the same under a minute on a prepared host
A mistake found later what was written after the moment chosen under a minute

Choices made

  • The log is shipped, not streamed: no port, certificate authority or certificates between the hosts. The price is a delay of up to NIK_ARCHIVE_TIMEOUT, 300 seconds by default.
  • The archive is on for every install, with two days kept.
  • The role of a server comes from its database, not from a variable, and each promotion raises a generation both hosts read.
  • A server that cannot reach the second host at start serves after 45 seconds with a notice. A host that cannot know it was replaced must be kept off by a person until rejoin.
  • Rejoining takes a fresh base backup, not pg_rewind; the old database is kept aside.
  • Going back to a named moment turns automation off until an administrator has looked: the restored server does not know the calls it made after that moment.
  • Interrupted, not guessed: sending again can open a second ticket, and assuming it happened can leave a host not isolated. An interrupted run waits for a person without limit.
  • A mirrored comment cut by a restart fails and waits for a person; an update is sent again.
  • Three tries, then set aside; the thresholds are fixed in the code.
  • The recovery tools run in a service of their own with no network, a read-only filesystem and no password: it reaches PostgreSQL through its socket.
  • The automation worker still does not hold the store: it is given each file as it lies sealed on the disk.

Known limits

  • Streaming replication is not built.
  • A call a playbook made on the old server after the last log that arrived is unknown to the promoted server and is made again. The window is the loss the command names.
  • A server that learns it was replaced takes no new step; a call already begun may still leave.
  • Three files on the second host are in clear: the heartbeat, the marker of a replaced server and the list of the store files it has (sizes and SHA-256 names).
  • Files rewritten in place (a capture's log, a mailbox file) exist in one version only.
  • Webhooks are sent at most once; there is no retry.
  • A connector of your own whose command changes something and does not say idempotent: false is repeated after a restart.
  • Under a storm of hard kills a step can be given up after three cuts.
  • The proof of a pair of hosts is not kept in the repository; restart-chaos.sh and recovery-proof.sh are, and neither runs in CI yet.

Not verified on real systems

  • Podman: the new recovery service, its socket volume and the standby's inbox have not run under it.
  • Two real hosts: the pair was two compose projects on one machine with an SFTP container each; a real sshd, a corporate network and the uid mapping of a rootless engine on the inbox were not met.
  • A large database or store: the proofs ran on a few hundred megabytes.
  • deploy/rollback.sh below 6.9 was not run on a stack.
  • Migrations 0052 and 0053 have not met the server.