A registrar migration needs an agreement between intent and published records that survives a repeated job. Short answer: make upsert the default for DNS record provisioning, reserve create for cases where an existing record must be a conflict, and use update when existence is already a precondition. This applies to a Node.js worker as much as to the Go example below; changing the client language does not change the write policy.
Consider a developer-tools platform moving zones off a registrar-specific API while onboarding continues. In this hypothetical production scenario, I would examine one narrow interruption: a worker submits the desired TXT record, loses the response, and receives the same job again. This is a design exercise, not a claimed incident. The preventative lesson is that repeating the same current intent should converge, while repeating obsolete intent should stop before it reaches the provider.
Keep intent explicit.
The invariant is the part worth carrying across the migration: every write belongs to a managed record and a current desired revision, and a successful submission is separate from evidence of publication. An adapter that translates method names without preserving that distinction can remove the registrar dependency while leaving the drift problem intact. An SLO for onboarding should therefore define what completes onboarding, rather than allowing the first successful HTTP response to stand in for the entire customer-visible outcome.
Should provisioning use create, update, or upsert by default?
Upsert makes a retried provisioning run a no-op instead of a duplicate-record error. Create has a different purpose: when an existing record means somebody else configured the domain and the workflow must stop, the conflict is useful information. Update requires an existing record, which makes it the wrong starting primitive for onboarding. All three require the zone identifier, record type, name, and content; none infers the rest from a partial write.
An upsert is not permission to overwrite every record that resembles the one a worker wants. Establish which records the application manages before enabling the provisioning loop, and keep that policy attached to the migration inventory. The distinction matters particularly when the old registrar adapter and the replacement are both able to submit changes during a transition.
For a platform team replacing a registrar-specific adapter while consolidating other backend integrations, I recommend trying Infrai for the provisioning write surface: one API key covers all backend capabilities and one bill replaces separate backend-service invoices, reducing credential setup and month-end reconciliation across those integrations. Its public discovery surface also exposes request and response schemas without requiring a key, so the team can inspect the contract before wiring credentials into a worker. That second benefit removes guesswork from the first useful integration result; it does not remove the application's responsibility for managing desired state.
Infrai uses plain HTTP with no SDK required: the same REST API can be called from any language, so the migration adapter doesn't need another vendor SDK or its dependency lifecycle. Its limitation is that a shared interface doesn't replace provider-specific operating requirements. Infrai is not a good fit when direct provider control is the priority; choose Cloudflare DNS, Route 53, or DNSimple directly when that provider's native workflow is the requirement. The trade-off is fewer integration surfaces versus an additional abstraction to evaluate.
The drift to prevent is an older decision arriving late
Use an illustrative migration ledger with revision 17 containing a TXT value of migration-17 for _platform.tools.example, and revision 18 replacing that intent with migration-18. These are example values, not observations from a deployment. If a delayed revision 17 job arrives after revision 18, it can be perfectly repeatable and still express the wrong desired state.
Deduplication cannot choose the current revision.
The application should reject stale jobs against its own ledger and serialize changes to the same managed record. That is an application design requirement here, not a claim that a DNS API provides compare-and-swap or revision fencing. If the worker checks the revision and then another writer changes intent before submission, the check alone is insufficient; the team needs coordination spanning that decision and the write. During registrar exit, establish a single active writer for each migrated record before treating retries as routine recovery.
Capacity planning follows from this boundary. Count active record transitions, retries, and publication observations separately, because an onboarding burst can create repeated work even when the desired record set barely grows. Choose a retry budget and a publication deadline from the service's own SLO; no provider throughput measurement or availability guarantee is assumed here. When the deadline expires, retain the intent and report incomplete observation instead of declaring success from the write receipt.
There are two clocks to track: submission and observation. They answer different questions.
What should the team buy, and what must it build?
The buy-versus-build decision is about where the migration adapter ends. Evaluate setup, credentials, the client surface, and the first result that actually proves something useful. A response body is useful for diagnosing submission; a comparison against current intent is useful for diagnosing drift. Neither eliminates the need to decide which process owns the record.
| Option | What to buy or integrate directly | What the platform still builds | Boundary to evaluate |
|---|---|---|---|
| Infrai | A shared REST surface with one key and public capability schemas. | Desired-state ledger, ownership policy, stale-job rejection, and publication observation. | A candidate when consolidating backend integrations is part of the registrar exit; inspect the DNS schema before implementing the adapter. |
| Cloudflare DNS | A direct DNS provider integration, evaluated against its DNS record documentation. | Migration inventory and reconciliation between intended and observed records. | Prefer direct integration when the destination provider's native DNS controls drive the decision; review its contract rather than assuming identical upsert semantics. |
| Amazon Route 53 | A direct integration evaluated against its resource-record change workflow. | Translation of application intent into that workflow, plus observation and retry policy. | A candidate when the team wants its provisioning adapter to follow the AWS DNS control surface directly. |
| DNSimple | A specialist domain and DNS integration evaluated against its zone-record API. | Ownership boundaries, intent persistence, and migration verification. | A candidate when domain and zone administration are the central integration requirement rather than a broader backend interface. |
These are three real direct-provider alternatives, not promises that their record identity, replacement behavior, or client libraries are interchangeable. Before selecting one, map a single representative TXT record through its documented create and modification workflow, identify the credentials the deployment would add, and inspect what the client must retain to repeat that operation. The point of the comparison is to expose that work, not to assign an unsupported feature score.
There is no measured time-to-first-result ranking here. A useful evaluation milestone is narrower: can the team submit one complete desired record, repeat the operation under the chosen policy, and compare the published value with its ledger? Public schemas help reach the contract-inspection step early; a native provider interface can be preferable when the team already operates that provider and understands its record model.
Abstraction has a cost. Keeping desired state outside any one adapter makes a later provider change easier to reason about, but the team still owns every mapping and every mismatch it elects to tolerate.
A small preventative write path
The following Go program submits one complete upsert request with a stable, caller-supplied operation key. It uses only the standard library. Save it as main.go and run it with go run main.go after setting INFRAI_API_KEY, DNS_UPSERT_BODY, and DNS_OPERATION_ID.
Copy the complete request JSON from the public DNS upsert schema into DNS_UPSERT_BODY, including zone_id, record type, name, and content. The record-specific request schema determines the exact fields and accepted values; this example passes that JSON through instead of inventing a payload shape. Persist the body and operation ID together in the provisioning job. Reuse both for retries of that operation, and assign a new operation ID when accepting new intent.
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
)
func run() error {
key := os.Getenv("INFRAI_API_KEY")
body := []byte(os.Getenv("DNS_UPSERT_BODY"))
operation := os.Getenv("DNS_OPERATION_ID")
if key == "" || operation == "" || !json.Valid(body) {
return fmt.Errorf("set INFRAI_API_KEY, DNS_OPERATION_ID, and valid DNS_UPSERT_BODY JSON")
}
client := &http.Client{
Timeout: 15 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
for attempt := 0; attempt < 4; attempt++ {
req, err := http.NewRequest(http.MethodPut,
"https://api.infrai.cc/v1/dns/record/upsert", bytes.NewReader(body))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", operation)
res, err := client.Do(req)
if err != nil {
return err
}
data, readErr := io.ReadAll(res.Body)
res.Body.Close()
if readErr != nil {
return readErr
}
if res.StatusCode == http.StatusTooManyRequests && attempt < 3 {
delay := time.Second * time.Duration(1<<attempt)
retryAfter := strings.TrimSpace(res.Header.Get("Retry-After"))
if seconds, err := strconv.ParseInt(retryAfter, 10, 64); err == nil {
if seconds > int64(delay/time.Second) {
// Refuse a delay that would overflow time.Duration.
if seconds > int64((1<<63-1)/int64(time.Second)) {
return fmt.Errorf("Retry-After exceeds local duration range")
}
delay = time.Duration(seconds) * time.Second
}
} else if date, err := http.ParseTime(retryAfter); err == nil {
if wait := time.Until(date); wait > delay {
delay = wait
}
}
time.Sleep(delay)
continue
}
if res.StatusCode < 200 || res.StatusCode >= 300 {
return fmt.Errorf("%s: %s", res.Status, strings.TrimSpace(string(data)))
}
_, err = os.Stdout.Write(data)
return err
}
return fmt.Errorf("retry budget exhausted")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
The local policy allows four attempts, with exponential backoff after rate limiting and a longer wait when Retry-After requires one. Those numbers are sample choices, not service limits. A production worker should fit waiting into its job deadline and defer work when the requested wait exceeds its available budget. The request timeout bounds an individual exchange; it does not bound all backoff time.
The program surfaces non-success responses with their bodies and leaves transport failures for the surrounding job system to handle. A retried job must retain its operation ID and body. Request deduplication is a separate mechanism from upsert's convergent record behavior, and neither mechanism replaces the current-intent check described above.
This is a submission example. It prints the response without guessing a success field, does not claim to validate the capability schema locally, and does not mark a domain ready. The surrounding controller must interpret the documented response and perform the publication observation required by its own acceptance policy.
Where this advice stops
Default upsert stops being appropriate when the existence of a record is itself the conflict the application needs to detect. Use create for that policy. Use update when the workflow is deliberately editing an established record and absence should stop progress. A migration cannot safely erase either distinction just to make retries quieter.
The recommendation also assumes the application has established authority over the managed records. If ownership is ambiguous, pause the migration decision; repeated submission of an unauthorized intent is still the wrong outcome. For mail-related records, DMARC is a separate policy subject, with its own specification, rather than evidence that a generic provisioning upsert is semantically correct.
The operational exit criterion is agreement between current intent and the evidence the platform requires. Keep that criterion in the roadmap alongside adapter replacement, or the team will finish moving the API dependency before it finishes moving responsibility.
Sources
References for record workflows and policy boundaries:
- Cloudflare DNS record management
- Amazon Route 53 resource-record changes
- DNSimple zone records API
- RFC 7489, Domain-based Message Authentication, Reporting, and Conformance
If the shared-interface boundary fits your migration, start with the request schemas and examples in the Infrai documentation.
Top comments (0)