From 508b9352e8c692ef137930cd128f66ba45d1da19 Mon Sep 17 00:00:00 2001 From: Bohdan Shulha Date: Mon, 26 Aug 2024 17:02:34 +0200 Subject: [PATCH] fix: #143 omit caddy configs for deleted services --- api-nodes/Http/Controllers/EventController.php | 1 + app/Models/Deployment.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/api-nodes/Http/Controllers/EventController.php b/api-nodes/Http/Controllers/EventController.php index 762a6e2..0374cb8 100644 --- a/api-nodes/Http/Controllers/EventController.php +++ b/api-nodes/Http/Controllers/EventController.php @@ -28,6 +28,7 @@ public function started(Node $node, AgentStartedEventData $data) $nodeAddresses = $swarm->nodes->pluck('data.address')->toArray(); $dockerServices = collect($swarm->services) ->filter(function ($service) { + // TODO: use some flags on the service to determine if it should be passed to DIRD return Str::contains($service->docker_name, 'caddy'); }) ->pluck('docker_name') diff --git a/app/Models/Deployment.php b/app/Models/Deployment.php index d30c2fc..ee6029a 100644 --- a/app/Models/Deployment.php +++ b/app/Models/Deployment.php @@ -64,6 +64,8 @@ public function scopeLatestDeployments(EloquentBuilder $query): EloquentBuilder $query ->selectRaw('max("latest_deployments_query"."id")') ->from('deployments', 'latest_deployments_query') + ->join('services', 'services.id', '=', 'latest_deployments_query.service_id') + ->whereNull('services.deleted_at') ->groupBy('latest_deployments_query.service_id'); }); }