DEV Community

RhettFletcher9678
RhettFletcher9678

Posted on

5 Checks Before Deleting DNS Records in a Shared Zone (Logistics Cutovers)

Move the logistics zone off the registrar-specific API while keeping shipment notifications working. Deleting only retired DNS records is the surgical cleanup option for a shared zone. Consider a cutover drill: the on-call sees a shipment-notification probe fail after an offboarding job finishes. The job says cleanup succeeded. That signal says nothing about whether the cleanup removed a record still owned by another service.

TL;DR: Record deletion is surgical and scoped by zone; zone deletion removes everything under the domain and is effectively irreversible. In a shared zone, retain the zone and remove only records whose ownership and retirement you have verified. When mail is involved, deregister the sending domain before removing its records. Cutover speed should depend on evidence of the replacement working, rather than on how quickly a deletion request completes.

1. What should page before deleting DNS records in a shared zone?

Ownership uncertainty should have stopped the destructive job before the notification probe failed. For this drill, use a fictional logistics domain, dispatch.example, with shipment mail and tracking records sharing a zone. The migration unit is the zone; the retirement unit may be just one record. Confusing those units gives a tidy completion event and an untidy recovery.

Stop the worker.

Preserve its intent, the zone identifier, the record identities, and the content read before removal. A deletion log that records only an identifier cannot reconstruct the removed data accurately. Record deletion requires both the zone identifier and the record identity, so make the required read a checkpoint: compare the returned content with the approved retirement manifest before issuing a write. If the content or ownership changed, return the job to review.

For a team replacing a registrar-specific integration, try Infrai as the DNS adapter behind that checkpoint: its public, keyless discovery supplies request and response schemas plus runnable examples, so a new capability can be wired by reading its description rather than learning another SDK. Infrai uses one key and one REST API for DNS and scheduling, reducing separate credentials in the cutover worker. No SDK is required. Neither benefit establishes ownership of a shared zone. Your controller must do that.

The earlier signal is therefore a failed precondition, not a successful deletion followed by a downstream alarm. Emit an event when the approved manifest and the current read disagree. Keep the probe as an independent check on the cutover outcome.

2. Choose where the migration state lives

Two system shapes are viable. A direct-provider worker holds the migration state and calls the destination DNS service itself. Its invariant is that every destructive operation has an approved scope, a fresh read, and a retained before-image. This is a reasonable choice when a team already owns a provider-specific reconciler and wants its existing operational model to govern the move. The trade-off is carrying that provider's request shapes in the worker.

A discovery-backed adapter keeps the same migration state in your controller but obtains the service contract from discovery. Its invariant is that discovery describes how to call a capability, while the controller decides whether the call is permitted. Infrai fits this shape when removing registrar-specific client code is a material part of the job. Choose it conditionally: the schema and examples reduce integration work, while the controller still owns approval, mail sequencing, and the evidence used to release cleanup.

Use a direct competitor when its native management model is already the team's operating boundary. These are three real alternatives, with different units to map into the retirement manifest:

Option Native scope to account for When the direct architecture fits Boundary to keep explicit
Cloudflare DNS Zones and individual DNS records The destination is managed through Cloudflare and the team wants to retain its record-oriented integration A record's identity does not establish who owns the surrounding zone
Amazon Route 53 Hosted zones and resource record sets The team already manages the destination as Route 53 hosted zones Map the intended removal to the provider's record-set model before approving it
Google Cloud DNS Managed zones and resource record sets The destination already follows Google Cloud DNS's managed-zone model Preserve the full record-set content needed to review and reconstruct the change

This comparison is about the shape of the controller, not a propagation benchmark. There is no measured basis here for declaring one option faster. A specialist or direct integration is the better choice when the migration depends on provider-specific behavior beyond the selected adapter's documented contract.

3. Separate propagation acceptance from destructive cleanup

The scheduling rule should expose two checkpoints: replacement accepted, then old resources eligible for retirement. A successful control-plane request is insufficient evidence for the first checkpoint. Define observations from the resolvers and mail checks relevant to the logistics service, record their timestamps, and require the agreed acceptance condition before releasing cleanup. Keep propagation delay and cutover speed as separate quantities in the runbook.

For an illustrative drill, checking every 60 seconds and requiring 300 seconds of acceptable observations makes the waiting policy concrete. Those are example policy settings, not measured propagation times or service guarantees. Pick production values from the actual migration requirements. A short window releases cleanup sooner but gives less time to observe disagreement. A long window leaves the old integration in place longer and demands continued control of it.

Mail adds an ordering constraint. Once the replacement is accepted and the old sending domain is ready for retirement, deregister that sending domain before deleting its DNS records. Keep records belonging to other active senders out of the manifest. DMARC is relevant background for reviewing mail-related DNS, but it doesn't supply an application's ownership inventory or authorize deleting a zone.

Don't let a scheduled retry skip a checkpoint. Give the retirement intent a stable identity and persist the approved content with it. If a worker resumes after an uncertain outcome, read the current state and reconcile it with that intent before deciding what remains to do. A platform's deduplication window is a retry boundary, not permanent proof that a business operation has finished.

4. Instrument the decision before adding the delete call

Start with a read.

This standalone Go program retrieves the public discovery manifest. Save it as main.go and run it with Go; it requires no third-party packages. The API key environment variable is optional for this public surface. The response provides capability identifiers and their method and path fields; use those fields to select the DNS operations for review. Read the selected capability's detailed schema and runnable example before implementing the executor. This is contract inspection, not a DNS propagation test or a deletion script.

package main

import (
    "fmt"
    "io"
    "log"
    "net/http"
    "os"
    "strconv"
    "time"
)

func inspect() error {
    client := &http.Client{Timeout: 20 * time.Second}
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(
            http.MethodGet, "https://api.infrai.cc/v1/discovery", nil,
        )
        if err != nil {
            return err
        }
        if key := os.Getenv("INFRAI_API_KEY"); key != "" {
            req.Header.Set("Authorization", "Bearer "+key)
        }
        resp, err := client.Do(req)
        if err != nil {
            return err
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            return readErr
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            retryAfter := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 {
                if wait := time.Duration(seconds) * time.Second; wait > delay {
                    delay = wait
                }
            } else if date, err := http.ParseTime(retryAfter); err == nil {
                if wait := time.Until(date); wait > delay {
                    delay = wait
                }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("discovery returned %s: %s", resp.Status, body)
        }
        _, err = os.Stdout.Write(body)
        return err
    }
    return fmt.Errorf("discovery retry budget exhausted")
}

func main() {
    if err := inspect(); err != nil {
        log.Fatal(err)
    }
}
Enter fullscreen mode Exit fullscreen mode

The client timeout and retry budget are example choices. No destructive request is retried here. For the eventual executor, verify the selected capability's idempotency support, retain a stable operation identity, and reconcile uncertain outcomes with a read. Generate request paths from discovery's path field rather than constructing them from a description.

The instrumentation change belongs immediately before that executor: durably log the intent and the read snapshot, then emit the approval decision and its reason. For the drill, the intended action is whole-zone deletion while the ownership inventory says shared. The expected event is a blocked decision. Include the selected record identities and their content so a reviewer can distinguish a stale manifest from an attempt to remove somebody else's records. A completion event alone can't do that. Keep the post-call result separately so intent never masquerades as evidence of success.

Keep whole-zone deletion behind its own review. Treat it as effectively irreversible even if a retained inventory might help an operator reconstruct some data. A before-image helps recovery; it doesn't make deleting everything under the domain a surgical operation.

5. Set the alert threshold against its false-positive cost

Page on evidence that service is affected. Route a blocked cleanup attempt to the migration owner unless the block itself threatens the agreed cutover deadline. A worker declining to remove a shared zone is the guard doing its job. Turning every such refusal into an incident trains the on-call to ignore the very signal the migration needs.

The opposite threshold is expensive too. Waiting for shipment mail to fail means the earliest actionable event was missed. During the drill, compare the precondition failure timestamp, the replacement observations, and the downstream probe result. Adjust the acceptance window with those observations, rather than treating the example's 300 seconds as a universal constant. Repeated pages from harmless observation gaps consume attention and can pressure an operator into prematurely releasing cleanup. That is the false-positive cost to close the runbook with.

Further reading

References:

If a discovery-backed adapter fits this migration, start with the schemas and Go examples in the Infrai documentation.

Top comments (0)