Skip to content
Sign inDashboard

Profile propagation

  1. The API (or opdns-cp admin profile set) saves the profile. In the same Postgres transaction, it writes an outbox row with the new version. The outbox is a table of changes that wait to be published.
  2. The publisher that holds the leader lock reads the outbox. It publishes the whole profile document on the JetStream stream profiles (subject profiles.<id>, one message kept per profile, header Opdns-Version). It marks a whole batch as published after NATS acknowledges it. Message-id deduplication makes a repeat after a crash harmless. If someone deleted the stream, the publisher creates it again.
  3. Every PoP (server location) receives the message through its NATS leaf node, and the edge applies it. The edge ignores any version that is not newer than the version it holds. A PoP that starts reads the newest snapshot (snapshots/latest.json in object storage). It then follows the stream from the sequence of the snapshot.

Postgres is the source of truth. Every repair below publishes again what Postgres holds, and never invents a version.

The control plane signs every profile that it hands out with Ed25519. A PoP or node can receive a forged or changed document through NATS, object storage or the API. If it does, it refuses the document.

What Signed by Signature
each profiles.<id> message the publisher headers Opdns-Signature (base64) and Opdns-Key-Id over "opdns-profile-sig/1\n" + id + "\n" + version + "\n" + body
each snapshot the publisher a minisign sidecar, profiles-<seq>.json.sig, written before snapshots/latest.json moves to it
a node’s profile pull (GET /v1/nodes/self/profile) the api profile_signature and profile_key_id in the response, over the same string with the profile’s compact JSON

The key id is the first 8 bytes of the SHA-256 of the public key, in hex. This is the same as for list signing keys.

The publisher and api roles read OPDNS_PROFILE_SIGNING_KEY (--profile-signing-key). The value is a comma-separated list of files. Each file holds hex Ed25519 seeds, one per line. The first key signs. The public half of every key is announced to nodes, at enrollment (profile_pubkey in the enrol response) and in every profile pull. As a result, nodes follow a rotation without help.

In development, opdns generates a missing file (with FILE.pub next to it) in the keys volume. Outside development, if the key is missing, both roles log a warning and publish unsigned profiles. Do not leave the key unset in production.

Edges verify with OPDNS_PROFILE_PUBLIC_KEYS (-profile-public-keys). The value is comma-separated hex keys, or files of hex keys. Any of these keys can verify. If keys are set, the edge refuses an unsigned or badly signed message or snapshot. It keeps the last good state that it has. An empty value means no verification, with a warning at boot outside development.

GET /versions on the admin port of an edge lists the key ids that it trusts (profile_key_ids). replay (below, and fleetctl profiles replay) copies the signature headers with each message.

Enrolled nodes trust the keys that the cloud announces from their enrollment on. Nodes enrolled earlier trust the keys from their first pull that announces one. Nodes keep these keys in profile_keys.json. You can pin the keys with cloud.profile_public_keys (Profile signing keys).

Metric Counts
opdns_edge_profile_signature_failures_total{source} messages (stream) and snapshots (snapshot) an edge refused
opdns_node_profile_signature_failures_total profile pulls a node refused

No alert rule watches these counters yet. An increase means a key mismatch after a failed rotation, or forged data in the path.

  1. Generate the new key. Add its public half to OPDNS_PROFILE_PUBLIC_KEYS of every edge, next to the old key. Then roll the edges.
  2. Add the new seed to the signing file as the second line. Restart the publisher and the api. Nodes now learn the new key from every pull, and the old key still signs.
  3. Move the new seed to the first line, and restart them. The new key now signs.
  4. Run opdns-cp admin profiles republish --all --yes. The message kept for every profile, and the next snapshot, then carry the new signature.
  5. Remove the old key from the signing file and from the edges.

A node continues to trust a key that the cloud stops announcing. It stops when its next pull confirms the new set.

Changes to these limits are planned:

  • The api role holds the signing key, because it signs node responses built from Postgres. A separate node key is the alternative.
  • A node trusts the first key it sees, unless cloud.profile_public_keys is pinned. To recover from a lost cloud key, you must delete its profile_keys.json by hand.
  • The stream keeps one message per profile. As a result, a refused forgery still replaces the genuine last message until republish.
  • reconcile does not verify signatures.
  • snapshots/latest.json itself is unsigned.
  • The edge trusts its local state file as it is.

While it leads, the publisher writes a reserved system profile, canary, again every --canary-interval (default 1 minute, 0 turns it off). It writes through the same outbox, so each write crosses the whole path. An edge can apply a new canary version live, not during the replay at boot. When it does, it reports this on the core NATS subject canary.applied.<pop>. The publisher subtracts its own write time from the arrival time of the report, on one clock. It exports these metrics:

Metric Is
opdns_cp_profile_propagation_seconds{pop} histogram of commit-to-applied time per PoP
opdns_cp_profile_canary_lag_seconds{pop,node} per PoP server: the lag of the newest canary, rising while the server has not applied it
opdns_cp_profile_canary_written_timestamp_seconds when the canary was last written

Every profiles message also carries the Opdns-Published-At and Opdns-Committed-At headers. The edges use them for their own publish-to-apply histogram (opdns_edge_profile_propagation_seconds). The target is under 2 seconds from commit to every PoP.

Alert Severity Fires when
ProfilePublisherNoLeader page no publisher held the leader lock for 2 minutes: nothing is published
ProfileOutboxStuck page the oldest unpublished outbox row is over 30 s old for 2 minutes
ProfileCommitToPublishSlow warn commit-to-publish p99 over 1 s for 10 minutes
ProfilePropagationCanarySlow warn the slowest server of a PoP is over 2 s behind the canary for 5 minutes
ProfilePropagationCanaryStalled page a PoP did not apply a canary for 5 minutes
ProfileCanaryNotWritten warn the canary was last written over 5 minutes ago

The fleet alerts ProfilePropagationSlow and ProfileStreamBehind watch the same path from the side of the edges.

Terminal window
opdns-cp admin profiles status
opdns-cp admin profiles reconcile
opdns-cp admin profiles reconcile --fix --yes
opdns-cp admin profiles replay --from 1234 --dry-run
opdns-cp admin profiles republish --id abc123,def456 --yes
opdns-cp admin profiles snapshot
Subcommand Does
status shows the first and last sequence of the stream, the message and profile counts, and the last message time. Also shows the outbox backlog and its oldest row, and the sequence, size and age of the latest snapshot
reconcile [--json] compares Postgres with the newest message per profile in the stream and with the latest snapshot, and lists every drift. Exits 3 if there is any drift
reconcile --fix [--wait 60s] publishes again, through the outbox, every drift that it can repair. Waits for the publisher to drain it, then compares again. Exits 3 if drift remains
replay --from SEQ [--dry-run] publishes again, unchanged, the newest message of every profile that has a message at or after SEQ (stream only, no database)
republish --id ID[,ID] | --all [--wait 60s] puts the current documents from Postgres in the queue again (deleted profiles as tombstones), and waits until the publisher drained them
snapshot writes a snapshot now, and prints its key, sequence and profile count

The drift kinds that reconcile reports:

Kind Means --fix repairs it
missing Postgres has the profile, the stream has no message for it yes
behind the stream holds an older version, and none is waiting in the outbox yes
stale deleted in Postgres, the stream still holds a live document yes
ahead the stream holds a newer version than Postgres no: investigate
unknown the stream holds a profile Postgres does not know no: investigate
snapshot_ahead the latest snapshot holds a newer version than Postgres no: investigate

A profile whose newer version is still in the outbox counts as in flight, not as drift. ahead and snapshot_ahead can follow a Postgres restore to an older backup. See Backups.

The command takes the same database, NATS (--nats-url) and object storage (--s3-*) settings as the other roles. Without object storage, the command skips the comparisons with the snapshot, and snapshot refuses to run. Republished rows go through the outbox with kind republish. Edges that already hold a version ignore them. Outside env=dev, republish and reconcile --fix need --yes. Both are logged with the actor cli:<user>@<host>.

fleetctl profiles status shows the applied stream sequence of each PoP (from Prometheus) and how far behind it is. fleetctl profiles replay is the same replay as above. The profile stream replay runbook in the operator repository says when to use each command.