tenant-converge DNS phase: cold-start chicken-and-egg + non-idempotent record creation #7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Two related bugs in
dito tenant-convergeDNS phase prevent cold-start convergence of a new tenant withdns.provider = "cloudflare":1. Cold-start chicken-and-egg
The DNS phase reads the Cloudflare API token from the tenant OpenBao at
https://keys.<domain>. Butkeys.<domain>only resolves after the DNS phase creates the A record for it. Without DNS records, the converge can't reach OpenBao to read the CF token to create DNS records.Workaround: manually create DNS records via the Cloudflare API, then ack
GATE-CF-TOKENto defer the DNS phase. But this leads to bug #2.2. Non-idempotent DNS record creation
When DNS records already exist (created manually or from a prior partial converge), the DNS phase tries to CREATE them again via the Cloudflare API. Cloudflare returns 400
"An A, AAAA, or CNAME record with that host already exists"(error code 81053). The converge treats this as a fatal error and stops.The DNS phase should check for existing records before creating (upsert, not create). Or use the Cloudflare API's upsert behavior.
Reproduction
dito tenant-init sjc ...(new tenant with cloudflare DNS)dito tenant-converge sjc --ack GATE-REBUILD-CONFIRM— DNS phase gates (GATE-CF-TOKEN) because OpenBao unreachable (no DNS records)dito tenant-converge sjc --ack GATE-REBUILD-CONFIRM— DNS phase runs, tries to CREATE records, gets 400 (already exists), fatal errorSuggested fixes
http://10.77.0.13:8200) when the public URL (https://keys.<domain>) is unreachable. Or support anOPENBAO_ADDRenv var override.Environment
tenant-initoutput also has a bug:sealConfigone-liner is missing a trailing semicolon (Nix syntax error)Both bugs are already fixed in the current codebase (v1.9.0).
Bug 1 (cold-start chicken-and-egg): The DNS phase now falls back to an SSH port-forward to the container's internal IP when the public OpenBao URL is unreachable. See
src/phases/dns.rs:245-251:There is also a
cf_token_unreachable_gate(dns.rs:68) that handles the unreachable case gracefully with an actionable gate message.Bug 2 (non-idempotent DNS creation): The DNS phase now uses
converge_cf_upsert(dns.rs:424) which callscf.ensure_record— an idempotent upsert that treats already-present records as success (line 482). AGATE-DNS-OVERWRITEgate handles records with different content before overwriting.Both fixes shipped between v1.5.4 and v1.9.0. Closing as already-fixed.