Operations
Commands assume the example stack (deploy/examples/compose.production.yml).
Abbreviate them with an alias:
alias sd='docker compose -f compose.production.yml'
What holds what
| Data | Where | Lose it and... |
|---|---|---|
| Zones, records, users, credentials, history | Postgres (postgres-data) | everything is gone: back it up |
| DNSSEC private keys | knot-primary-data, directory keys (Knot's KASP database) | signed zones get new keys; every DS record at the registrar must be replaced, and validating resolvers fail until it is: back it up |
Vault key SALT_DNS_VAULT_KEY (and retired keys) | your .env / secret store | the TSIG secrets in Postgres cannot be read: back it up, away from the database backup |
| Knot configuration database, zone files, journal | knot-primary-data | rebuilt from Postgres, see below |
| Edge zone copies | knot-edge-*-data | fetched again from the primary |
Health and logs
GET /upanswers200 okwhen the process is running. Use it for liveness. The image'sHEALTHCHECKuses it.GET /readyanswers200when Postgres, the Knot control socket and the job queue (Oban) all work,503when one does not:{"status":"unavailable","role":"single","epoch":null,"checks":{"postgres":"ok","knot":"error","oban":"ok"}}. Use it for readiness and for monitoring. It reveals only which check failed; the reason is in the log (health check knot failed: ...).roleissingle(no cluster),leaderorfollower;epochis the lease epoch while the node leads (Several replicas).- Neither needs authentication, and neither is cached.
/readyhas the usual per-address rate limit,/uphas none. - Logs go to standard output.
SALT_DNS_LOG_FORMAT=jsonwrites one JSON object per line for a log collector. Secrets are removed from log lines (configuration). - Watch
/ready, disk space of the three volumes, Postgres, and the age of your last backup.
Backups
Take both backups at the same time of day, and test restoring them.
Postgres:
sd exec -T postgres pg_dump -U salt_dns -Fc salt_dns > salt_dns-$(date +%F).dump
Restore into an empty database with pg_restore -U salt_dns -d salt_dns --clean.
Use the Postgres tooling you already trust (continuous archiving, snapshots)
if you have it; this is the minimum.
DNSSEC keys (KASP): copy the keys directory of the primary's /storage
volume while the primary is running (it is a small LMDB database; use Knot's
own export for a guaranteed-consistent copy):
sd exec knot-primary keymgr -C /storage/confdb example.org list # the keys of one zone
sd exec knot-primary tar -C /storage -cf - keys > kasp-$(date +%F).tar
Store the archive encrypted; it holds private keys. If a zone's keys are lost,
roll the DS record at the registrar after the new keys are created
(keymgr ... ds prints it, the console shows it too).
Secrets: keep .env (or your secret store entry) with the vault keys
separately from the database dump. A dump alone cannot be decrypted; a dump
plus the vault key can.
Rebuilding Knot from Postgres
Postgres is the system of record: every zone's records are in it. If the primary's volume is lost, or you replace the primary:
Restore the
keysdirectory if you have it (otherwise accept new DNSSEC keys and replace the DS records).Start the primary with an empty
/storage. The entrypoint imports its configuration on first start.Compare every zone with Knot and create what is missing. This also happens by itself every ten minutes (
SALT_DNS_RECONCILE_CRON); to do it now:sd exec app /app/bin/salt_dns rpc 'IO.inspect(SaltDns.Knot.Scheduler.run_once())' # %{zones: 42, failed: []}failedlists zones that could not be written, with the reason.rpctalks to the running node. A single node starts with Erlang distribution on the loopback address only (rel/env.sh.eex), so this works inside the container and nowhere else. If you setRELEASE_DISTRIBUTION=noneit does not exist andrpcfails with "the node is not alive"; leave the variable unset, or usenamefor the cluster (thenRELEASE_NODEandRELEASE_COOKIEapply).The edges fetch the zones again by themselves: Salt rewrites the edge catalog (
edge.catalog.invalid, one record per active zone, refreshed with every reconcile), the primary notifies the edges, and they interpret it. To rewrite it now:sd exec app /app/bin/salt_dns rpc 'IO.inspect(SaltDns.Knot.EdgeCatalog.refresh_sync())'Check
dig @edge SOA example.org.
The same operation repairs drift: reconciling a healthy system changes nothing.
Changing the Knot configuration
The primary's configuration database (/storage/confdb) is created from
knot/primary.conf on the first start only. Salt then changes it at run
time (zones, per-zone DNSSEC policy). To change something the application does
not manage (for example a new edge, or rotating the transfer key), use
knotc against the running primary:
sd exec knot-primary knotc -s /run/knot/knot.sock conf-begin
sd exec knot-primary knotc -s /run/knot/knot.sock conf-set 'remote[edge-1].address' 203.0.113.10@53
sd exec knot-primary knotc -s /run/knot/knot.sock conf-commit
or delete /storage/confdb and restart (it is imported again; zones and keys
are untouched, and Salt re-adds the zones on the next reconcile). Edge
configuration is rendered from the environment at every start.
Rotating KNOT_TRANSFER_KEY_SECRET is done by changing it in .env, updating
the primary's key with conf-set 'key[edge-transfer].secret', and restarting
the edges.
Upgrades
Read the CHANGELOG for the versions between yours and the new one. Upgrade one release at a time.
Take a Postgres backup.
Build or pull the new image.
Run the migrations as a separate step, while the old version still runs:
sd run --rm app /app/bin/migrateStart the new version:
sd up -d app. (The example'scommandalso runs the migrations at start, which is harmless when there is nothing to do.)Check
/ready, the logs, and sign in.
Two-step migrations. Migrations must work for the version that is running and the version you are starting, so that step 4 can run before step 5 and a rollback of the application (not of the database) is safe. Therefore a change that removes or renames something takes two releases:
- Release N adds the new column or table, writes to both, and reads the new one. Nothing is removed.
- Release N+1 (after everyone is on N) removes the old column or table.
New columns are nullable or have defaults, and an index on a big table is created concurrently. This is why you upgrade one release at a time.
Rolling back. Restore the previous image. Do not roll the database back
unless a release says it is needed; if it is, run
bin/salt_dns eval 'SaltDns.Release.rollback(SaltDns.Repo, VERSION)' with the
migration version it names, or restore the backup from step 2.
Rotating the vault key
The vault key encrypts the TSIG secrets stored in Postgres (AES-256-GCM, each
value labelled with the id of the key that encrypted it). Every encrypted
column is listed in SaltDns.Encrypted.Registry (today the TSIG secrets of
credentials and of secondaries, and the DNSSEC private keys kept for failover), and a test fails when a new encrypted field is
not listed, so rotate_vault always covers all of them. To replace the key:
Generate a new key:
openssl rand -base64 32.Set
SALT_DNS_VAULT_KEYto the new key andSALT_DNS_VAULT_KEY_IDto a new id (v2), and move the old key intoSALT_DNS_VAULT_RETIRED_KEYS=v1:OLDKEY. Restart the app. Everything still reads, new secrets use the new key.Re-encrypt everything stored with the old key:
sd exec app /app/bin/salt_dns eval 'IO.inspect(SaltDns.Release.rotate_vault())' # 17 (the number of secrets rewritten, across all tables)It is safe to repeat.
Remove
SALT_DNS_VAULT_RETIRED_KEYS, restart, and check that TSIG updates still verify. Keep the old key in a safe place until you have a backup made after step 3: older database backups need it.
If you suspect the key leaked, also issue new TSIG keys: rotating the vault key protects the stored copies, not secrets an attacker already has.
Ending a person's sessions
A session that began with single sign-on lasts SALT_DNS_OIDC_SESSION_HOURS
hours (default 12). A session from a password lasts 14 days. When a person is
disabled at the identity provider, Salt does not hear of it. They lose Salt
within at most that many hours, because the next sign-in goes through the
provider and is refused. A page they already have open can keep working until
it is loaded again or reconnects.
If the identity provider is set up for back-channel logout, it tells Salt
when a person is signed out or disabled there, and Salt ends the sessions
named (one provider session when the notice carries a sid, all of the
person's otherwise), including open pages. See
Back-channel logout. Without it, or when
the call does not arrive, the limit above applies.
To end every session of one person at once, whatever the reason:
sd exec app /app/bin/salt_dns eval 'SaltDns.Release.sign_out_user("person@example.org")'
# Ended 3 session(s) of person@example.org.
An address that no user has prints a message and changes nothing. The command cannot reach pages that are already open, because it runs in its own process.
When a member is removed
Removing a member on the members page changes what their sessions may do:
- If the person has no membership left in any organisation, all their
sessions end at once and their open pages are disconnected. They can sign in
again, but they see no organisation (and with
SALT_DNS_OIDC_AUTO_CREATE=invitedthey cannot create one unless they own one elsewhere). - If they still belong to another organisation, their sessions stay. Their open pages are disconnected, so the browser loads them again with the rights they have now. The organisation they lost is no longer reachable.
- Changing a role does the same disconnect and keeps every session.
The disconnect reaches every open page of that person's sessions, in all their organisations, not only the one that changed: the page's channel is named after the session, not the organisation. A person can see a page reload when an admin of another organisation changes their role there. Nothing is lost by it.
A console page reads the person's organisations and role when it opens. A change an action makes is checked again against the database, so a removed person cannot change anything through a page that was already open. The disconnect closes the gap for what the page still shows.
Inviting people from the command line
On an installation with SALT_DNS_OIDC_AUTO_CREATE=invited, a fresh database
has no organisation and nobody who may create one. The operator makes the
first organisation, then invites the first owner. Both commands print what
they did and change only the database. Nothing is sent to the person: tell
them to sign in with that e-mail address.
sd exec app /app/bin/salt_dns eval 'SaltDns.Release.create_organisation("My company")'
# Created organisation 1 (My company).
sd exec app /app/bin/salt_dns eval 'SaltDns.Release.invite("owner@example.org", 1, :owner)'
# Invited owner@example.org to My company as owner (invitation 1, valid until ...).
invite(email, organisation_id, role) takes :owner, :admin, :editor or
:viewer. It stops with a message when the organisation does not exist, the
address already has an account (add that person on the members page instead),
or the address is already invited. The invitation lasts 14 days. It can be
revoked on the members page by an owner or admin of that organisation.
Those pages end when they are next loaded. To cut them off at once, restart the
application. The person can sign in again unless they are disabled at the
provider, so disable them there first.
Sessions that began before an upgrade to this feature keep the 14 days they were given. Run the command for anyone who must go now.
Zone ownership checks
A new zone is pending until Salt finds proof of ownership: a delegation to
your nameservers (read from the parent zone's servers), or the
_salt-dns-challenge.<zone> TXT record with the zone's token. Checks run when you
press "Check now" or call POST /api/v1/zones/<zone>/verify, then automatically
after 1, 5 and 15 minutes and then hourly until SALT_DNS_VERIFICATION_DAYS
(default 7) have passed.
How the TXT record is looked up. A recursive resolver that was asked for the name before the record existed keeps the "no such record" answer for the zone's negative TTL (RFC 2308), often an hour, even when the record exists by now. A check therefore never takes "missing" from one resolver:
- every resolver in
SALT_DNS_RESOLVERSis asked; a record found at any of them counts; - if none has it, the zone's own authoritative servers are asked directly, without recursion (found through the resolvers: the SOA and NS of the zone that contains the name, then their addresses). A record at any of them counts, as in ACME validation, so a server that has not received the record yet does not matter;
- only when neither has it is the result
txt_challenge: missing.
The authoritative servers' addresses come from DNS, so they are filtered like every
address Salt connects to: private, loopback and link-local addresses are never
asked (a zone whose NS names point there cannot make Salt query your
network), and at most six servers are tried.
SALT_DNS_REFUSE_PRIVATE_RESOLVERS=true additionally drops private resolvers.
What you see. txt_challenge: found and the zone becomes active at that check.
missing means neither the resolvers nor the authoritative servers had the record at
that moment; if you just added it, the next check (at most an hour away, usually
minutes; press "Check now" to ask at once) finds it. If the zone's authoritative
servers cannot be asked (none reachable, no public address), the answer of the
resolvers decides, so a resolver's stale negative can still show missing until its
negative TTL ends; adding the record at every authoritative server, or waiting that
TTL, fixes it. error: <reason> (timeout, servfail, refused) is inconclusive and
changes nothing.
Changing the nameserver names
SALT_DNS_NAMESERVERS / SALT_DNS_NS (the apex NS set), SALT_DNS_SOA_MNAME and
SALT_DNS_SOA_RNAME apply to every zone, in Knot and in the listener's answers
(SaltDns.Apex). After a change and a restart, the next reconcile (at start and every
SALT_DNS_RECONCILE_CRON) rewrites the NS set and the SOA of every zone Knot already
has and raises the SOA serial (to the current time or the old serial plus one,
whichever is higher), so secondaries notice and transfer; signed zones are signed
again by Knot. Run the reconcile at once as shown under "Rebuilding Knot from
Postgres". Zones written by a version before this behaviour (all with
ns1.example.net) are corrected the same way.
Switching DNSSEC off
Switching a signed zone off is guided: the DS must leave the parent first, and only after every resolver cache has forgotten it does Salt unsign the zone (otherwise validating resolvers answer SERVFAIL for the whole domain). The wait after the DS is seen to be gone is the longest observed DS TTL or negative TTL plus a five minute margin. If no TTL was ever observed (the zone was switched on and off before a DS reached the parent) the wait is one hour plus the margin instead of a day: there is no DS for a resolver to remember except one published between two of our checks.
Behind PgBouncer
Connect directly to Postgres where you can. If DATABASE_URL has to go through
PgBouncer in transaction pooling mode (a shared cluster), set
SALT_DNS_DATABASE_POOLER=true. Each transaction may then run on a different
server connection, so Salt:
- sends unnamed prepared statements (a named one would not exist on the next connection);
- gives Oban the
Oban.Notifiers.PGnotifier instead of Postgres LISTEN/NOTIFY, which a pooled connection cannot keep. That notifier works inside one node and across clustered nodes; jobs are still stored in Postgres.
Nothing else needs a session: the zone lock is SELECT ... FOR UPDATE inside a
transaction, Ecto's migration lock is a table lock inside the migration's
transaction (not an advisory lock), and the code uses no SET, temporary
tables or session advisory locks. SALT_DNS_MIGRATION_DATABASE_URL is an
optional direct URL for bin/migrate only, for a migration that does need a
session. The dev/ stack has an optional PgBouncer (dev/compose --profile pooler)
and the CI runs the zone, writer, listener, ownership and job tests through it.
Behind a reverse proxy
Rate limits are per client address. Behind a proxy that address is the
proxy's, unless you set SALT_DNS_TRUSTED_PROXIES to the proxy's address or
range and make the proxy set SALT_DNS_CLIENT_IP_HEADER itself, overwriting
what the client sent. The header is read from the right, skipping trusted hops,
so a client cannot choose its own address. Check it: after a few failed API
requests from your laptop, the log line's remote_ip is your address, not the
proxy's.
Edges on separate hosts
The example puts everything on one host so that you can try it. In production run each edge on its own host and network:
- Run
knot-edge(the same image,knot/edge.conf,knot/edge-entrypoint.shandknot/render.sh) on each host withKNOT_TRANSFER_KEY_SECRETandKNOT_PRIMARY_ADDRESS(the primary's address as the edge sees it), and publish port 53 on the host's public address. - On the primary set
KNOT_EDGE_1_ADDRESSandKNOT_EDGE_2_ADDRESSto the edges' addresses, and publish the primary's port 53 on an address the edges can reach (a private network or VPN, never the internet). - Firewall: only the edges reach the primary's port 53; the control socket stays local to the primary and the app.
Every transfer and notify is authenticated with the TSIG key
edge-transfer; the address checks are an extra, not a substitute.
Several replicas
The control plane can run as any number of identical replicas, each with its own
Knot (a StatefulSet in Kubernetes). No replica is special and none has a name you
configure. SALT_DNS_CLUSTER=true turns it on; without it there is one node that
always drives its Knot, exactly as before.
- One primary at a time, decided by the database. The replica that holds the
lease row in Postgres drives its Knot as the primary and signs; every other
replica's Knot is a secondary of it with every zone and signature. A replica
that dies, or is stopped cleanly, hands the lease over (a clean stop within one renew interval, a
crash within
SALT_DNS_LEASE_TTLplus one renew interval, 15 and 5 seconds by default). Any replica takes console, API and update requests; the work that has to reach Knot goes to the holder over the cluster as a speed-up, and the holder's 5-second catch-up poll of Postgres makes it correct when a message is lost or the cluster is split. - Why the lease and not a cluster registry. A registry such as Horde (or
:global) is eventually consistent: during a network split it can start the controller on both sides, and two Knot primaries signing the same zones is the one failure this design must not have. The lease is a single row in the database all replicas share, with an epoch as fencing token, so it cannot be split; the cluster only carries messages and tells replicas sooner that the holder is gone. - The fence is local and conservative. After each confirmed renewal the
holder may write for at most the TTL minus one renew interval, measured on its
own monotonic clock (a jump of the wall clock changes nothing), without asking
the database. A holder that cannot renew (Postgres unreachable, queries
hanging: they time out after one renew interval) stops writing at that point
and demotes its Knot, at least one renew interval before the lease can expire
for anybody else. Cutting the holder off from Postgres while it stays in the
cluster therefore moves the lease; splitting the cluster while the database is
fine changes nothing, because only the database decides.
SALT_DNS_LEASE_RENEWmust be shorter than half ofSALT_DNS_LEASE_TTL; the application refuses to start otherwise. - Followers find the primary without names. The holder writes the transfer
address of its Knot (
SALT_DNS_KNOT_ADDRESS, default this host's first non-loopback IPv4 address and port 5300) into the lease row. Every follower reads it and points its Knot'speerremote at it within a few seconds of a change. The address comes from the database and ends up in Knot's configuration, so it must be an IP address and a port and nothing else (SaltDns.Knot.PeerAddress); anything else is logged and ignored. The primary lets followers transfer by TSIG key alone, so adding or removing replicas needs no configuration change on the others. - Readiness.
/readyof a replica in a cluster has an extra check,replica: it fails while the replica is being promoted or demoted and, for a follower, until its Knot has loaded every zone (a new replica's Knot is empty for some seconds). Use/readyas the readiness probe and/upas the liveness probe. The Postgres, Knot and Oban parts of/readymay be up to 3 s old (ready_cache_ms); thereplicapart never is, so a promotion or demotion that starts shows at the next request. - What stays per replica. The rate limits and the flood guard of the update listener, and their caches, are in each replica's memory: they protect each replica's own connection pool, and N replicas allow N times the abuse limit. Replay protection of signed updates is in Postgres and shared.
How long things take
Measured with scripts/replicas/run.sh (three replicas of the production image,
one Postgres, lease TTL 15 s and renew 5 s, a test host, several runs on 2026-11-11 and 12, the last on the tree with the replica containers, the announcement and the provisioning changes; the range is the fastest and slowest run):
| What | Measured | Bound |
|---|---|---|
| Three replicas ready after start | 2.6 to 5.7 s | |
Primary killed (docker kill) to a new primary | 12.1 to 14.4 s | TTL + renew + promotion: at most about 21 s |
| Primary cut off from Postgres to a new primary | 13.3 to 17.2 s | the same |
Primary stopped cleanly (docker stop) to a new primary | 0.5 to 4.4 s | up to a renew interval (the other replicas look at the lease only every renew interval, so where in that interval the stop falls decides) + promotion: about 5.5 s at most |
| Rolling update of three replicas, longest time without a primary | 1.8 to 2.5 s | |
| Scale 3 to 5 replicas, all ready | 11.3 to 14.7 s | |
| Scale 5 to 2, one primary again | 2.5 to 2.6 s | |
| A change made through a follower, visible on every Knot (see below) | 0.3 s | with the announcement described below; 13.7 s before it existed (the followers' poll) |
| Replicas split from each other, database fine | nothing changes hands |
After a crash or a cut-off the wait is the lease, not detection. The old primary last renewed up to one renew interval ago, so its lease runs out between TTL minus one renew interval and TTL after the failure; the other replicas try to take it every renew interval; the new primary then needs about a second to promote its Knot (it imports the keys of signed zones first). Worst case: TTL + renew + promotion, 21 s with the defaults; 14 to 17 s were measured. The old primary stops writing and demotes its Knot after the fence time (7.5 s with the defaults), well before its lease can expire for anybody else, so two primaries never overlap. A shorter TTL shortens the wait and raises the Postgres load by one query per replica per renew interval; the renew interval must stay under half of the TTL. A clean stop releases the lease at once; the new primary is the first other replica that looks at it, which is within one renew interval, so a clean stop takes 0.5 to 5.5 s, not a fixed time.
Followers learn of a change in two ways. When the primary has changed a zone
in its Knot it announces the zone on the cluster, and each follower asks its own
Knot to check the primary for that zone right away (zone-refresh, within a
fraction of a second). Without that announcement (a message lost, a replica not
yet in the cluster) the follower's Knot polls its primary at least every 15 s
(refresh-max-interval), which is what the first measurement of this row (13.7 s,
constant, a poll in each run's schedule) was. Either way the database is the
truth and the primary's own Knot has the change at once.
Examples for Docker Compose and Kubernetes, and a harness that runs the failure
scenarios and prints the measured times, are in deploy/examples/replicas/ and
scripts/replicas/.
How a replica takes over
The details behind Several replicas. Of the replicas, one is the leader: it writes to its Knot and signs. The others are followers: their Knots are secondaries of the leader's, holding every zone with its signatures, and their applications serve the API and console. If the leader goes away a follower takes over by itself.
Without SALT_DNS_CLUSTER=true none of this exists and nothing changes.
How it works
- The lease. A row in Postgres (
leases) says which replica leads. The holder keeps it forSALT_DNS_LEASE_TTLseconds (default 15) and renews it everySALT_DNS_LEASE_RENEWseconds (default a third of the TTL). Only the database's clock counts. Each change of holder raises theepoch. A replica is identified in the lease by its label (the host name) plus a random token made at boot, so two replicas never share a lease whatever they are called. A clean stop releases the lease at once. - Fencing. The leader writes to Knot only while its last renewal is at most 1.5 renew intervals old, judged on its own monotonic clock, with no database call. A leader that loses Postgres (or is cut off from it) therefore stops writing within one renew interval, long before another replica can take the lease. Knot keeps serving what it has; changes wait. When the lease can no longer be ours (a whole TTL without a renewal) the replica demotes itself.
- Changes made through any replica's API are committed in Postgres. The
others learn of them over the Erlang cluster (Phoenix PubSub) and the
leader applies them to Knot in order. Postgres has every change, so a message
that does not arrive (the replicas cannot reach each other while all reach
Postgres) costs seconds, not a sweep: the leader compares the zones' versions in
Postgres with what its writers have applied every 5 seconds and reconciles a zone
that is behind at two polls in a row (
salt_dns_knot_catch_up_zones_total). - The follower's Knot has an explicit zone for every zone in Postgres
(template
follower:master: peer), refreshed every 15 seconds and when the leader notifies it. It needs no keys to serve signed zones. - DNSSEC keys are copied from the leader's key store into Postgres every 15
seconds and after each key change (
dnssec_keys, private keys encrypted with the vault key). The new leader imports them with their timers before it signs, so key ids, tags, DS records and the DNSKEY set stay the same and validators notice nothing. A signed zone with no exported key is not given new keys (that would break the chain of trust): it stays unsigned on the new leader,salt_dns.failover.keys_missingcounts it, and the log names it. - Takeover takes at most TTL plus one renew interval, plus the time to
promote (about a second per hundred zones). The new leader turns each zone
into a primary in place (Knot keeps the data and the signatures; with
serial-policy: unixtimethe serial never goes backwards), switches signing on, then reconciles everything from Postgres and only then accepts changes. - Demotion (a replica that lost the lease, or restarts): first its writers stop, then every zone becomes a secondary of the new leader and is retransferred, so anything the old leader wrote that the new one never saw is replaced. A replica that boots is always a follower until it wins the lease.
Watching it
GET /readyshowsroleandepochon each replica: exactly oneleader.- Prometheus (
/metrics, scrape every replica):salt_dns_leader_epoch,salt_dns_leader_lease_age_milliseconds(the age of the last renewal, -1 on a follower),salt_dns_leader_role(0 follower, 1 leader, 2 single),salt_dns_leader_knot_primary, and the counterssalt_dns_failover_promoted_total,_demoted_total,_keys_missing_total. Leader-only work (the DNSSEC status poll, DNSSEC and reconcile jobs) runs on the leader only; on a follower the DNSSEC gauges are not reported. - Alerts:
deploy/examples/prometheus/alerts.yml, groupsalt-dns-cluster(no leader for two minutes, two leaders, a stale lease, keys missing). Also watch the follower's SOA serial against the leader's (dig SOA zone @replica-aagainst another replica) and/readyon every replica.
Limits to know
- Postgres is the single point. If it is down no replica can take the lease and the leader stops writing after one renew interval; DNS keeps answering from Knot, changes wait. Run Postgres replicated and fail it over on its own terms.
- A stopped, killed or hung application next to a running Knot leaves that
Knot a signing primary nobody drives. Three things close that:
- a clean stop (every deploy) demotes the Knot first: the application's
Failoverprocess makes the Knot a secondary before the lease is released; - for a kill, a crash or a hang,
knot-watchdog.shruns in the Knot container (the entrypoint starts it when the marker file/storage/.salt-dns-clusterexists). The leading application touches/storage/.salt-dns-heartbeat(SALT_DNS_HEARTBEAT_FILE) with every confirmed renewal; when the file is older thanWATCHDOG_STALE_SECONDS(default 16: the default lease TTL of 15 s plus one) the watchdog applies the follower configuration through the control socket. It is a file and a shell loop, with no network, credentials or extra service; its price is that after a hard kill two Knots can still be signing until the watchdog has run: at mostWATCHDOG_STALE_SECONDSplusWATCHDOG_INTERVAL(default 5) = 21 s after the leader's last renewal, which is also the worst time for another replica to take over, so the overlap is seconds, not a lease. Why these numbers: a file older than the lease TTL means the lease has run out (the leader touches it after each confirmed renewal), so demoting earlier only repeats the application's own fence; the check runs every renew interval. Keep the stale time aboveSALT_DNS_LEASE_TTLand the interval at mostSALT_DNS_LEASE_RENEWif you change those; cluster-reset.shmakes a Knot that restarts a follower before it starts, and the entrypoint refuses to startknotdwhen that fails or the scripts are not mounted.SaltDnsFollowerSigningalerts when a follower's Knot is configured to sign. While two Knots do sign, an edge may take either one's copy; it ends with the demotion.
- a clean stop (every deploy) demotes the Knot first: the application's
- Frozen zones. A signed zone whose keys cannot be imported on promotion is
not given new keys (the DS at the parent would no longer match) and is not
stripped either: it keeps the signed copy it had and accepts no change: not
record changes, and not settings or DNSSEC changes either (REST and PowerDNS
answer 503, dynamic updates SERVFAIL, the console is read-only with a banner).
Disabling and deleting the zone remain possible. The copy does not last for the
signatures' lifetime. The zone is a secondary of a peer that no longer leads,
so Knot expires it when the zone's SOA expire time has passed since the freeze,
which an organisation may set as low as one day, and then stops answering for
it. Restore the keys well before that:
SaltDnsFrozenLongalerts after four hours, and the banner and the 503 say so./readyshowsfrozen_zones,SaltDnsZonesFrozenalerts. Restore the keys (thednssec_keysrows or the old leader's key store) and restart the application; promotion runs again (the leader also retries the import by itself every 30 seconds, and thaws the zone when it works).SaltDnsKeyExportFailingwarns while the leader cannot export its keys, which is how you find out before a takeover. - Clocks. Signature validity needs NTP as before. The lease uses only the
database's clock, and the leader's fence is the local monotonic clock, 7.5 s
(half the default TTL) short of the lease. The design assumes the Postgres
server's clock does not step forward by more than that while a lease is in
force; NTP slewing never does, a manual
date -sor a virtual machine resuming can. If it happens, up to that many seconds can pass with two writers. Do not step the database server's clock on a live cluster. - The heartbeat file must be writable. If the application cannot touch it
(a read-only volume, another owner) it logs the error and
SaltDnsHeartbeatFailingfires: the watchdog is then either not protecting the replica (no file) or, if the file worked before, demotes this healthy leader when it goes stale. - Deleted zones lose their DNSSEC keys with the zone (a later zone of the same name does not inherit them); a disabled zone keeps them. The follower deletes the files and journal of zones it stops following.