From eedc3faba38c278a13efe213bc62d69d1db4cd6a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 18 Oct 2023 14:14:40 +0200 Subject: [PATCH 1/4] fix: labels --- .../Livewire/Project/Application/General.php | 4 ++++ app/Models/Service.php | 2 +- bootstrap/helpers/docker.php | 16 +++++++--------- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index c99650912..b4ebfff5d 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -119,6 +119,7 @@ class General extends Component public function instantSave() { // @TODO: find another way - if possible + $force_https = $this->application->settings->is_force_https_enabled; $this->application->settings->is_static = $this->is_static; if ($this->is_static) { $this->application->ports_exposes = 80; @@ -137,6 +138,9 @@ class General extends Component $this->emit('success', 'Application settings updated!'); $this->checkLabelUpdates(); $this->isConfigurationChanged = $this->application->isConfigurationChanged(); + if ($force_https !== $this->is_force_https_enabled) { + $this->resetDefaultLabels(false); + } } public function getWildcardDomain() diff --git a/app/Models/Service.php b/app/Models/Service.php index 9d14e18eb..95fe826fb 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -538,7 +538,7 @@ class Service extends BaseModel $serviceLabels = $serviceLabels->merge($defaultLabels); if (!$isDatabase && $fqdns->count() > 0) { if ($fqdns) { - $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik($fqdns, true)); + $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik($this->uuid, $fqdns, true)); } } data_set($service, 'labels', $serviceLabels->toArray()); diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 4fc87ac13..179abecb9 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -147,12 +147,11 @@ function defaultLabels($id, $name, $pull_request_id = 0, string $type = 'applica } return $labels; } -function fqdnLabelsForTraefik(Collection $domains, bool $is_force_https_enabled, $onlyPort = null) +function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_https_enabled, $onlyPort = null) { $labels = collect([]); $labels->push('traefik.enable=true'); - foreach ($domains as $domain) { - $uuid = (string)new Cuid2(7); + foreach ($domains as $loop => $domain) { $url = Url::fromString($domain); $host = $url->getHost(); $path = $url->getPath(); @@ -161,8 +160,8 @@ function fqdnLabelsForTraefik(Collection $domains, bool $is_force_https_enabled, if (is_null($port) && !is_null($onlyPort)) { $port = $onlyPort; } - $http_label = "{$uuid}-http"; - $https_label = "{$uuid}-https"; + $http_label = "{$uuid}-{$loop}-http"; + $https_label = "{$uuid}-{$loop}-https"; if ($schema === 'https') { // Set labels for https @@ -213,13 +212,13 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview $onlyPort = $ports[0]; } $pull_request_id = data_get($preview, 'pull_request_id', 0); - $container_name = generateApplicationContainerName($application, $pull_request_id); + // $container_name = generateApplicationContainerName($application, $pull_request_id); $appId = $application->id; if ($pull_request_id !== 0 && $pull_request_id !== null) { $appId = $appId . '-pr-' . $pull_request_id; } $labels = collect([]); - $labels = $labels->merge(defaultLabels($appId, $container_name, $pull_request_id)); + $labels = $labels->merge(defaultLabels($appId, $application->uuid, $pull_request_id)); if ($application->fqdn) { if ($pull_request_id !== 0) { $domains = Str::of(data_get($preview, 'fqdn'))->explode(','); @@ -227,8 +226,7 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview $domains = Str::of(data_get($application, 'fqdn'))->explode(','); } // Add Traefik labels no matter which proxy is selected - $labels = $labels->merge(fqdnLabelsForTraefik($domains, $application->settings->is_force_https_enabled, $onlyPort)); + $labels = $labels->merge(fqdnLabelsForTraefik($application->uuid, $domains, $application->settings->is_force_https_enabled, $onlyPort)); } - ray($labels); return $labels->all(); } diff --git a/config/sentry.php b/config/sentry.php index 61c18786f..c6c30f70a 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.94', + 'release' => '4.0.0-beta.95', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 4daf3b070..b5427b80b 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 18 Oct 2023 14:22:09 +0200 Subject: [PATCH 2/4] fix: email channel no recepients --- app/Notifications/Channels/EmailChannel.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index 5cd4ceaeb..cd6dc4b56 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -30,7 +30,12 @@ class EmailChannel ); } catch (Exception $e) { ray($e->getMessage()); - send_internal_notification("EmailChannel error: {$e->getMessage()}. Failed to send email to: " . implode(', ', $recepients) . " with subject: {$mailMessage->subject}"); + $message = "EmailChannel error: {$e->getMessage()}. Failed to send email to:"; + if (isset($recepients)) { + $message .= implode(', ', $recepients); + } + $message .= " with subject: {$mailMessage->subject}"; + send_internal_notification($message); throw $e; } } From 4f588ced96b99af48f88de57f739917db3464572 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 18 Oct 2023 14:43:48 +0200 Subject: [PATCH 3/4] call handle not matter what --- app/Jobs/ContainerStatusJob.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 1c8cf1919..9b5f9dc48 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -19,6 +19,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted @@ -40,9 +41,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted public function __construct(public Server $server) { - if (isDev()) { - $this->handle(); - } + $this->handle(); } public function handle() @@ -76,6 +75,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $this->server->update([ 'unreachable_count' => 0, ]); + Log::info("Server {$this->server->id} is reachable."); } else { $serverUptimeCheckNumber++; $this->server->settings()->update([ @@ -129,7 +129,6 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted } catch (\Throwable $e) { ray($e); } - } else { $this->server->proxy->status = data_get($foundProxyContainer, 'State.Status'); $this->server->save(); From 3a27d13c3eaa9cc7831fde74a458776e4ae4e332 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 18 Oct 2023 14:46:26 +0200 Subject: [PATCH 4/4] fix --- app/Jobs/ContainerStatusJob.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 9b5f9dc48..4e9f53990 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -19,7 +19,6 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Arr; -use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted @@ -75,7 +74,6 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $this->server->update([ 'unreachable_count' => 0, ]); - Log::info("Server {$this->server->id} is reachable."); } else { $serverUptimeCheckNumber++; $this->server->settings()->update([