DEV Community

mT41Gzp73rc6
mT41Gzp73rc6

Posted on

Publisher DNS Onboarding: A Guide to Scheduled TTL Lowering and Restoration

The operational bill for a publisher's domain onboarding includes DNS mutations, scheduled execution, verification reads, and retained evidence. Count the work first: each changed record needs three scheduled mutations and a content check after each. Across N records, that's 3N mutations and at least 3N post-change checks. These are workload counts, not provider prices. Repeated verification becomes the dominant term if unresolved customer requests keep polling indefinitely; the planned mutations stay fixed.

Short answer: capture the original TTL, schedule its reduction a day before the DNS cutover, then schedule the change and exact TTL restoration together. Verify record content after each step. For a media platform onboarding a publisher, domain ownership must be proven before onboarding completes; a successful DNS write alone doesn't supply that proof.

Keep evidence small.

Who owns the zone, and who can authorize the change?

A customer-owned zone puts the publisher in control of record changes. Your platform can supply instructions and evaluate the resulting proof, but an internal schedule cannot promise that the customer will execute a change on time. Treat confirmed TTL lowering as a gate. A platform-owned zone gives your automation control over the schedule; that control does not prove that an external publisher owns a separate domain.

This distinction matters more than a convenient API. If the platform creates its own record and then approves the customer because that record exists, the test has established the platform's ability to edit its own zone. Tie approval to the domain and the customer action required by your ownership-verification policy. Specify that policy before implementing the scheduler, including who may approve a change and what happens when a publisher's DNS administrator misses the planned window.

Use the illustrative publisher domain newsroom.example throughout one plan. Bind it to the exact record identity and approved content, not merely the tenant name. Two records belonging to one publisher can have different jobs. A verification change must not rewrite unrelated mail records. Nor is domain ownership a deliverability test: DMARC has separate policy and identifier-alignment concerns, and onboarding approval does not establish them.

How should pre-change TTL lowering and restore be scheduled around a DNS cutover?

Lowering the TTL during the cutover does not shorten the lifetime of an old answer already cached by a resolver. The previous TTL still governs that answer. Schedule lowering a day ahead, and evaluate that lead time against the captured original TTL rather than treating a calendar reminder as proof that caches have expired.

Record the original value first. Restoring a convenient default discards part of the customer's configuration.

Don't guess it.

Make three scheduled steps part of one approved plan. Lowering preserves original content and changes only the TTL. Cutover applies approved replacement content while retaining the reduced TTL. Restoration keeps the replacement content and reinstates the captured TTL. Check content after every step: a TTL-only operation that rewrites a verification value can invalidate the onboarding evidence even though the TTL itself looks correct. Read back record identity, content, and TTL; an acknowledgement of a write is insufficient.

Restoration needs a gate too. Its scheduled time is an instruction to evaluate the approved transition, not permission to proceed after an unverified cutover. Keep disputed plans pending for review. Schedule restoration when approving the change so it doesn't become an informal task after onboarding has finished.

Choose automation around authority and evidence

Cloudflare DNS, Amazon Route 53, and Google Cloud DNS provide record-management interfaces. None of those interfaces makes the application's ownership decision for it. Choose around existing zone authority, then implement the approval policy explicitly. This comparison makes no latency or uptime ranking.

Option Appropriate fit Limitation for this workflow
Cloudflare DNS The publisher already manages the relevant zone there and can authorize its changes. Your platform still needs authorized access or a customer-executed step.
Amazon Route 53 The zone is already managed through the team's AWS environment. Record changes and the onboarding approval remain separate responsibilities.
Google Cloud DNS The zone already belongs to the team's Google Cloud environment. Access to that zone does not prove an external publisher owns another domain.

Infrai provides one REST API, no SDK required, with one key and one bill for DNS and scheduled work. This reduces credentials and invoice reconciliation across onboarding services. The unified API is plain HTTP, callable from any language: the DNS adapter and scheduling worker can use the same HTTP client conventions instead of installing separate SDKs. It covers 295 routes across 20 modules. Its public, self-describing discovery supplies request and response schemas without a key, and documented capabilities include runnable examples in 10 languages. That helps a reviewer check the actual mutation contract before granting a worker write authority. The trade-off is adopting another platform where customer access controls may already be settled. Prefer the existing provider in that case; don't require a zone migration merely to simplify the scheduler.

A minimal executable schedule plan

This Python example builds the three scheduled steps and checks expected record state. It runs locally with the standard library, prints a JSON plan, and performs no network writes. The domain, dates, content, and TTLs are illustrative inputs, not observed customer data or provider defaults. Replace the snapshot with actual record state captured before approval.

The 24-hour lead is explicit. An original TTL longer than that lead is rejected so the operator must choose an earlier lowering time. The restore time is an approved input, not a universal propagation interval. The example uses Python for the planning logic; a Node.js worker would need to enforce the same state transitions.

import json
from datetime import datetime, timedelta, timezone

original = {
    "name": "_ownership.newsroom.example",
    "type": "TXT",
    "content": "previous-proof",
    "ttl": 3600,
}
approved_content = "publisher-proof-example"
cutover_at = datetime(2026, 12, 8, 12, tzinfo=timezone.utc)
restore_at = datetime(2026, 12, 9, 12, tzinfo=timezone.utc)
lower_at = cutover_at - timedelta(days=1)
reduced_ttl = 300

if original["ttl"] > (cutover_at - lower_at).total_seconds():
    raise ValueError("Schedule TTL lowering earlier")
if not 0 < reduced_ttl < original["ttl"]:
    raise ValueError("Reduced TTL must be positive and lower")
if restore_at <= cutover_at:
    raise ValueError("Restore must follow cutover")

states = [
    ("lower", lower_at, original["content"], reduced_ttl),
    ("cutover", cutover_at, approved_content, reduced_ttl),
    ("restore", restore_at, approved_content, original["ttl"]),
]
plan = []
for step, due, content, ttl in states:
    plan.append({
        "step": step,
        "due_at": due.isoformat(),
        "expected_record": dict(original, content=content, ttl=ttl),
    })

def verify_record(observed, expected):
    for field in ("name", "type", "content", "ttl"):
        if observed.get(field) != expected[field]:
            raise ValueError(f"Record mismatch: {field}")

for item in plan:
    verify_record(dict(item["expected_record"]), item["expected_record"])
print(json.dumps(plan, indent=2))
Enter fullscreen mode Exit fullscreen mode

These are local plan fields, not an API request schema. The final loop checks example fixtures; a worker must use a record read back from its DNS provider after each mutation. Persist the plan and its approval before registering jobs. Preserve record identity in the adapter and stop for review if a later read shows an unrelated edit instead of overwriting it.

There is a deliberate limit: generating a plan doesn't execute it. Production execution needs durable scheduling, replay-safe transitions, and a separately recorded ownership-verification result before onboarding completes. Replaying a completed step must not reapply an obsolete state after a later step has succeeded. Reading the authoritative record also cannot establish that every recursive resolver has discarded its previous answer.

Before binding the plan to remote writes, this read-only companion inspects discovery for the record-update operation. Set INFRAI_BASE_URL to the documented API base including its version prefix, and supply INFRAI_API_KEY through the environment. Discovery itself is public; this request uses the credential convention the worker will need. The program prints the matching capability metadata for schema review. It does not execute the plan or approve ownership.

import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, urlopen

base = os.environ["INFRAI_BASE_URL"].rstrip("/")
key = os.environ["INFRAI_API_KEY"]
request = Request(
    base + "/discovery",
    headers={"Authorization": f"Bearer {key}"},
    method="GET",
)
for attempt in range(5):
    try:
        with urlopen(request, timeout=30) as response:
            manifest = json.load(response)
        break
    except HTTPError as error:
        detail = error.read().decode("utf-8", errors="replace")
        if error.code != 429 or attempt == 4:
            raise RuntimeError(f"HTTP {error.code}: {detail}") from error
        retry_after = error.headers.get("Retry-After")
        delay = 2 ** attempt
        if retry_after:
            try:
                delay = max(delay, float(retry_after))
            except ValueError:
                due = parsedate_to_datetime(retry_after)
                delay = max(delay, (due - datetime.now(timezone.utc)).total_seconds())
        time.sleep(delay)

matches = [
    item for item in manifest["capabilities"]
    if item["method"] == "PATCH"
    and item["path"] == "/v1/dns/record/update"
]
if len(matches) != 1:
    raise RuntimeError("Expected exactly one matching capability")
print(json.dumps(matches[0], indent=2))
Enter fullscreen mode Exit fullscreen mode

This read is safe to retry. Mutation retries need idempotency and state checks; reviewing a schema doesn't establish permission to modify a customer's zone.

Retain the decision, bound the observation history

The change that moves the growing work term is to bound repeated verification. Check after each mutation and use an explicit deadline for unresolved customer action. Avoid indefinitely polling an onboarding attempt. For an illustrative budget, a limit of K additional checks per record bounds the planned post-change and waiting checks at (3 + K)N. Choose K and the deadline together, with room for customers whose DNS administrator works on a different schedule. This is a workload bound, not a provider billing formula or a measured saving.

Retain original TTL, record identity, approved replacement content, scheduled times, outcomes, and the evidence behind approval. Protect access to that evidence. A verification workflow should not become an archive of unrelated publisher DNS configuration. The retention period needs operational and compliance requirements; the TTL mechanism supplies no universal duration.

Deliberately stop keeping duplicate unchanged observations after the policy's retention window. Keep the approved plan and decisive observations for the period your review process requires. The cost of discarding intermediate samples is forensic precision: if a publisher disputes when a record became visible, you may explain approval and restoration but cannot reconstruct every resolver's view between checks. Accept that limit before deleting history.

Further reading

References for DNS behavior, mail-policy boundaries, and the provider interfaces compared above:

Top comments (0)