mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
- Proxy: list and delete Traefik ACME certificates from the server proxy page via new TraefikAcmeService and Get/DeleteTraefikCertificate actions - DNS: track ownership and cross-resource references for managed DNS records so records are only deleted when no longer referenced; release records asynchronously on resource deletion via ReleaseManagedDnsRecordsJob and ManagedDnsRecordCleanup; harden Cloudflare provider deletion results - Databases: fail closed on start when prerequisites or the CA certificate are missing (DatabaseStartException, Server::ensureCaCertificate) and clean up stale start activities via ResourceStartActivity - Webhooks: throttle repeated manual webhook signature failures for GitHub, GitLab, Gitea and Bitbucket - Deployments: improve compose build-context handling and compose file load error reporting - Install scripts: rework terminal UI output in install.sh (stable and nightly) - Misc: settings sidebar accordion fixes, log drain toggle rollback, add Serverside to README sponsors - Add migrations and tests covering the above
53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use App\Jobs\ReleaseManagedDnsRecordsJob;
|
|
use App\Models\Application;
|
|
use App\Models\ApplicationPreview;
|
|
use App\Models\ManagedDnsRecordReference;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Throwable;
|
|
|
|
/**
|
|
* Releases a resource's managed DNS references after it is deleted (soft or force delete).
|
|
* The cleanup runs in a queued job after commit so provider errors never block the deletion.
|
|
*/
|
|
trait ReleasesManagedDnsRecords
|
|
{
|
|
public static function bootReleasesManagedDnsRecords(): void
|
|
{
|
|
static::deleted(function (Model $resource): void {
|
|
try {
|
|
if (! self::hasManagedDnsReferences($resource)) {
|
|
return;
|
|
}
|
|
|
|
ReleaseManagedDnsRecordsJob::dispatch($resource->getMorphClass(), $resource->getKey())->afterCommit();
|
|
} catch (Throwable $e) {
|
|
Log::warning('Could not queue managed DNS cleanup for a deleted resource.', [
|
|
'resource_type' => $resource->getMorphClass(),
|
|
'resource_id' => $resource->getKey(),
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
}
|
|
});
|
|
}
|
|
|
|
private static function hasManagedDnsReferences(Model $resource): bool
|
|
{
|
|
$query = ManagedDnsRecordReference::query()->where(fn ($query) => $query
|
|
->where('resource_type', $resource->getMorphClass())
|
|
->where('resource_id', $resource->getKey()));
|
|
|
|
if ($resource instanceof Application) {
|
|
$query->orWhere(fn ($query) => $query
|
|
->where('resource_type', (new ApplicationPreview)->getMorphClass())
|
|
->whereIn('resource_id', ApplicationPreview::withTrashed()->where('application_id', $resource->getKey())->select('id')));
|
|
}
|
|
|
|
return $query->exists();
|
|
}
|
|
}
|