fix(dns): deleting a record that is already gone is success
A lost response, or a retry after a later step failed, made every further attempt a 404 — and the host impossible to purge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/portal-design
parent
9f8659da32
commit
69043f9ffc
|
|
@ -50,6 +50,15 @@ class HttpHetznerDnsClient implements HetznerDnsClient
|
|||
|
||||
public function deleteRecord(string $recordId): void
|
||||
{
|
||||
$this->http()->delete("/records/{$recordId}")->throw();
|
||||
$response = $this->http()->delete("/records/{$recordId}");
|
||||
|
||||
// A record that is already gone is the outcome we wanted. Without this,
|
||||
// a lost response or a retry after a later failure turns every further
|
||||
// attempt into a 404 — and a host that can then never be purged.
|
||||
if ($response->notFound()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response->throw();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,3 +103,13 @@ it('reports node capacity for a host (FakeProxmoxClient)', function () {
|
|||
->and($client->nodeStatus('pve')['memory']['total'])->toBeGreaterThan(0)
|
||||
->and($client->nodeStorage('pve')[0]['total'])->toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('treats an already-deleted DNS record as done', function () {
|
||||
Illuminate\Support\Facades\Http::fake([
|
||||
'*' => Illuminate\Support\Facades\Http::response(['error' => 'not found'], 404),
|
||||
]);
|
||||
|
||||
// A lost response, or a retry after a later step failed, must not make the
|
||||
// record impossible to clean up — and its host impossible to purge.
|
||||
(new App\Services\Dns\HttpHetznerDnsClient)->deleteRecord('rec-123');
|
||||
})->throwsNoExceptions();
|
||||
|
|
|
|||
Loading…
Reference in New Issue