fix(engine-b): idempotent local DNS record (firstOrCreate on record_id)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat/portal-design
nexxo 2026-07-25 13:08:13 +02:00
parent 96aceeeaa1
commit d7c2edb1df
1 changed files with 6 additions and 5 deletions

View File

@ -31,13 +31,14 @@ class ConfigureDnsAndTls extends CustomerStep
$host = $instance->host;
$fqdn = $instance->subdomain.'.'.config('provisioning.dns.zone');
// DNS — persist the record id [E] before anything downstream.
// DNS — provider upsert is idempotent; the local row uses firstOrCreate on
// the record id and is written BEFORE the breadcrumb (the short-circuit guard).
if (! $this->hasResource($run, 'dns_record_id')) {
$recordId = $this->dns->upsertRecord($fqdn, 'A', $host->public_ip);
$instance->dnsRecords()->create([
'provider' => 'hetzner', 'record_id' => $recordId,
'fqdn' => $fqdn, 'type' => 'A', 'value' => $host->public_ip,
]);
$instance->dnsRecords()->firstOrCreate(
['record_id' => $recordId],
['provider' => 'hetzner', 'fqdn' => $fqdn, 'type' => 'A', 'value' => $host->public_ip],
);
$this->recordResource($run, $host, 'dns_record_id', $recordId);
}