Admit a logistics tenant's mail subdomain only after its published MX destinations and priorities match the receiving provider's approved plan. Publish that provider's records directly. A forwarding host belongs in a transition with an explicit exit condition.
TL;DR: Treat drift as an admission decision. An accepted DNS write doesn't establish the tenant's intended mail route, and another queue attempt cannot repair an ambiguous plan. Preserve explicit MX priorities, compare the complete record set, and keep inbound routing separate from outbound sending authorization.
Consider a proposed onboarding workflow: a Node.js service automatically assigns dispatch.north-depot.example to a logistics tenant, then schedules its mail configuration. The interesting question is when that service may mark the tenant ready. This runbook uses discrepancy classification as the decision tool: distinguish an incorrect destination, an incorrect priority, and an obsolete plan before choosing the next action. The Go example below implements the admission check without making a DNS write. All names and numeric priorities in that example are synthetic.
Should provider MX records replace a forwarding host before tenant admission?
Start with the receiving arrangement. The provider's approved destinations and explicit priorities are the intent; records observed at the tenant's exact mail owner name are the publication. Compare both. A hostname match with a different priority is still drift, while a published forwarding destination leaves the final receiver behind an extra hop that complicates later delivery debugging.
Hold the admission.
MX priorities express routing preference. Multiple records with distinct priorities express a primary and a fallback; omitting priority makes routing unpredictable. Preserve the values the receiving provider specifies rather than choosing a backup host because its name looks plausible. The numbers 10 and 20 below illustrate two distinct priorities. They aren't deployment instructions or a claim about any provider's configuration.
A useful incident note identifies the discrepancy before proposing a repair. “Mail setup failed” cannot tell the next worker whether it should restore a destination or stop applying an old tenant revision. “Approved priority 10, observed priority 20 for the same destination” can. Keep the plan revision, owner name, desired set, and observation together so that a repeated queue delivery has something more precise to act on than the last worker's completion flag. This is a proposed runbook contract, not a claim that every DNS API supplies those fields.
An MX match has a narrow meaning: the inbound route agrees with the plan. It doesn't make outbound mail trusted. Sending authorization and authentication need their own review; DMARC is relevant to that separate boundary. Don't let a green routing check close both tasks.
Classify the discrepancy before spending a retry
Use three outcomes for this admission check: match, drift, or observation error. Keep the third outcome intact. Converting an unsuccessful inventory read into an empty record set encourages a worker to publish replacements without knowing what already exists.
For a valid observation, compare the entire destination and priority set. Then decide whether the current intent still authorizes a write. A delayed onboarding job can carry an older plan even if its payload is perfectly valid. Idempotency prevents the same logical operation from being applied twice; it doesn't decide which of two different revisions should win. Serialize changes for the same owner name and reread the approved revision before mutation. The extra read adds work, but it gives the worker a reason to discard stale intent instead of replaying it.
The following standalone Go program demonstrates the distinction between matching destinations and matching a plan. Save it as main.go and run it with Go. Its synthetic observation changes one priority from 10 to 20, so it prints hold tenant admission: MX drift. No API credentials or network access are required.
package main
import (
"fmt"
"sort"
"strings"
)
type MX struct {
Host string
Priority uint16
}
func normalize(input []MX) []MX {
output := append([]MX(nil), input...)
for i := range output {
output[i].Host = strings.TrimSuffix(strings.ToLower(output[i].Host), ".")
}
sort.Slice(output, func(i, j int) bool {
if output[i].Host == output[j].Host {
return output[i].Priority < output[j].Priority
}
return output[i].Host < output[j].Host
})
return output
}
func equalPlan(want, got []MX) bool {
if len(want) != len(got) {
return false
}
a, b := normalize(want), normalize(got)
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
func main() {
want := []MX{{Host: "primary.example", Priority: 10}, {Host: "fallback.example", Priority: 20}}
got := []MX{{Host: "fallback.example.", Priority: 20}, {Host: "primary.example.", Priority: 20}}
if !equalPlan(want, got) {
fmt.Println("hold tenant admission: MX drift")
return
}
fmt.Println("MX plan matches")
}
Order doesn't matter to this comparison. Priority does. The function normalizes hostname case and a trailing dot, compares record counts, and preserves repeated entries instead of hiding them in a map. Its input contract is deliberately small: two already validated record lists for one exact owner name. It doesn't perform DNS observation, detect an omitted priority before parsing, validate mailbox acceptance, or decide which revision is current. Those checks belong around the comparison, where the worker still has the original plan and observation result.
Require priority explicitly in the approved input. A numeric Go field's zero value cannot tell you whether an upstream field was absent; validate presence before constructing these records. That trap matters because an innocent-looking default can erase the very discrepancy the admission check is supposed to catch.
For actual publication, use the chosen operation's documented request schema and idempotency mechanism. Attach retries to the same approved logical operation, inspect response status, and preserve error details. On HTTP 429, honor Retry-After when present and use exponential backoff with a bounded retry budget. A retry is justified by a recoverable request outcome and current intent, not merely by the existence of another queued delivery.
Check the schema first.
This second standalone Go program reads the selected DNS capability's public discovery document before the worker's publication adapter is written. Set INFRAI_BASE_URL to the service's documented HTTPS API base including its version prefix, INFRAI_API_KEY to your key, and DNS_CAPABILITY_ID to the exact identifier selected from the public discovery inventory. Save this program separately as main.go. Discovery requires no key; the sample includes Bearer authentication to demonstrate the convention used by the eventual adapter. It prints the schema document rather than inventing a DNS write payload.
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
func inspect() error {
base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
key := os.Getenv("INFRAI_API_KEY")
id := os.Getenv("DNS_CAPABILITY_ID")
parsed, err := url.Parse(base)
if err != nil || parsed.Scheme != "https" || parsed.Host == "" || key == "" || id == "" {
return fmt.Errorf("set an HTTPS INFRAI_BASE_URL, INFRAI_API_KEY, and DNS_CAPABILITY_ID")
}
client := &http.Client{
Timeout: 15 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodGet, base+"/discovery/"+url.PathEscape(id), nil)
if err != nil {
return err
}
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 < 2 {
delay := time.Second * time.Duration(1<<attempt)
retry := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
if seconds > 60 {
return fmt.Errorf("retry deferred beyond the 60-second wait budget")
}
if candidate := time.Duration(seconds) * time.Second; candidate > delay {
delay = candidate
}
} else if date, err := http.ParseTime(retry); err == nil {
if candidate := time.Until(date); candidate > delay {
delay = candidate
}
}
if delay > 60*time.Second {
return fmt.Errorf("retry deferred beyond this tool's budget: %s", delay)
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("discovery HTTP %d: %s", resp.StatusCode, body)
}
fmt.Println(string(body))
return nil
}
return fmt.Errorf("retry budget exhausted")
}
func main() {
if err := inspect(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
The 15-second request timeout, three attempts, and 60-second maximum wait are illustrative tool limits, not service guarantees. If Retry-After exceeds the wait budget, the tool exits for later scheduling rather than retrying early. This read doesn't mutate records and needs no write idempotency key. Its limitation is concrete: a schema read establishes the adapter contract, not the tenant's published MX state.
Keep the raw observation alongside its normalized comparison result. Otherwise, the next operator sees only “drift” and cannot tell whether the difference was a missing fallback, a priority change, or an unexpected forwarding destination. For this proposed workflow, an observation error holds admission and schedules another read; a confirmed mismatch requires checking the current approved revision before any write. Neither condition authorizes blindly appending records.
Choose a publishing surface that preserves inspectable intent
The decision is operational ownership: where can the team compare approved tenant intent with published records and make a controlled correction? A new API interface doesn't improve that comparison if the worker discards priorities or treats every delivery as an instruction to append another record.
| Option | A reasonable fit | Selection boundary |
|---|---|---|
| Cloudflare DNS | Keep tenant publication with an existing Cloudflare DNS workflow | Review its DNS record API contract; retain the provider-approved destination and priority pairs outside the request representation |
| Amazon Route 53 | Keep publication with a team already responsible for the AWS hosted zone | Use its record-set change model deliberately; acceptance of a change is a different checkpoint from the admission comparison |
| DNSimple | Keep domain operations with a team already using its domain and record workflow | Check the record API contract and preserve the tenant's complete approved MX set across retries |
These are alternatives for publishing DNS, not a ranking of mail receivers. Favor the existing owner when moving the zone would add a second migration merely to automate tenant records. Route 53 is the better choice when the deciding requirement is to keep that responsibility within an existing AWS zone workflow; Cloudflare DNS or DNSimple may fit better when that is already where the team manages the domain. Compare their documented change contracts against the worker's needs rather than inferring a delivery guarantee from an API response.
Infrai offers a plain REST API with one key and one bill across 295 routes in 20 modules. That single key reduces credential management when tenant onboarding spans several backend services. The Node.js coordinator or a Go worker can send HTTP requests without installing a service-specific SDK or maintaining its client-library version. Its public, unauthenticated discovery surface exposes request and response schemas, so the team can inspect the publication contract before wiring credentials into the worker. A separate advantage is credential consolidation: a single API key covers 295 routes across 20 modules, with one bill. For a tenant onboarding workflow using several backend services, that means fewer credentials to distribute across the coordinator and its workers. Runnable examples in 10 languages also let the team review the Go and JavaScript integration patterns against the same capability contract. That breadth is useful only if the workflow actually needs it; adopting another publishing surface solely to set MX priorities adds integration work without changing the admission rule.
The trade-off is adopting another control surface. It is not a fit if the only requirement is MX publication in an already managed AWS hosted zone; prefer Route 53 there. The limitation of a unified API is that it doesn't replace the application's tenant-intent ledger or the admission comparison.
Choose the smallest ownership change that leaves the intended record set inspectable. None of these choices makes a forwarding host equivalent to a provider destination or turns an accepted write into evidence of mailbox delivery.
Verify the tenant route before releasing dependent work
Verification should answer a narrow question first: does the observed MX set at dispatch.north-depot.example match the current approved set, including every explicit priority? Record the observation result separately from the publication response. If the read fails, retain the observation-error state; don't report either a match or an empty zone.
Then verify the receiving arrangement through a controlled inbound message to the tenant's intended mailbox. Inspect the destination the message actually reaches. A matching record set and a received message answer different questions, so keep both results in the tenant's onboarding evidence. This is an acceptance procedure, not a measured delivery guarantee or a promise about observation timing.
Keep sending authorization separate.
The practical release condition for this proposed workflow is a current plan revision, a matching observed set, and a checked receiving destination. If a forwarding host remains during transition, record its intended final receiver and the condition for retiring it. “Forwarding works” is insufficient evidence that the provider's direct MX plan has been published.
Roll back the approved set rather than replaying an old job
Before changing tenant records, retain the previous approved destinations and priorities. If verification shows drift, hold dependent onboarding work, inspect the current revision, and decide whether to correct the new plan or restore the previous receiving arrangement. A rollback should be a newly authorized operation with its own stable retry identity, not permission for every delayed worker to resume an older plan.
Restore the complete approved set and repeat the same observation and receiving checks. Don't declare recovery from a successful write response alone. A forwarding host is acceptable as a deliberately approved transition step, with its destination and exit condition recorded; it shouldn't become the undocumented permanent route because the queue eventually stopped retrying.
The incident record should finish with the actual discrepancy and the action that resolved it. “Priority restored from 20 to approved value 10” is useful for the synthetic example here. “Retried successfully” loses the reason the tenant was held.
Top comments (0)