From a922f2fedfc633bdbe33426711e346811ed9b61e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 1 Oct 2023 18:13:34 +0200 Subject: [PATCH 1/3] version++ --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 58b909f0a..b2cf7844d 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.55', + 'release' => '4.0.0-beta.56', // 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 c70227f5a..3a4bcf65b 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Sun, 1 Oct 2023 18:14:13 +0200 Subject: [PATCH 2/3] feat: able to disable container healthchecks fix: dockerfile based deployments have hc off by default --- .../Livewire/Project/New/SimpleDockerfile.php | 1 + .../Livewire/Project/Shared/HealthChecks.php | 10 ++++- app/Jobs/ApplicationDeploymentJob.php | 7 ++++ app/Models/Application.php | 8 ++++ ..._add_healthcheck_disable_to_apps_table.php | 28 +++++++++++++ .../project/shared/health-checks.blade.php | 39 ++++++++++--------- 6 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php diff --git a/app/Http/Livewire/Project/New/SimpleDockerfile.php b/app/Http/Livewire/Project/New/SimpleDockerfile.php index 8a1d2c024..07a9ec88a 100644 --- a/app/Http/Livewire/Project/New/SimpleDockerfile.php +++ b/app/Http/Livewire/Project/New/SimpleDockerfile.php @@ -59,6 +59,7 @@ CMD ["nginx", "-g", "daemon off;"] 'environment_id' => $environment->id, 'destination_id' => $destination->id, 'destination_type' => $destination_class, + 'health_check_enabled' => false, 'source_id' => 0, 'source_type' => GithubApp::class ]); diff --git a/app/Http/Livewire/Project/Shared/HealthChecks.php b/app/Http/Livewire/Project/Shared/HealthChecks.php index 62a0d8dc0..1c783abec 100644 --- a/app/Http/Livewire/Project/Shared/HealthChecks.php +++ b/app/Http/Livewire/Project/Shared/HealthChecks.php @@ -9,6 +9,7 @@ class HealthChecks extends Component public $resource; protected $rules = [ + 'resource.health_check_enabled' => 'boolean', 'resource.health_check_path' => 'string', 'resource.health_check_port' => 'nullable|string', 'resource.health_check_host' => 'string', @@ -22,12 +23,19 @@ class HealthChecks extends Component 'resource.health_check_start_period' => 'integer', ]; + public function instantSave() + { + $this->resource->save(); + $this->emit('success', 'Health check updated.'); + + + } public function submit() { try { $this->validate(); $this->resource->save(); - $this->emit('saved'); + $this->emit('success', 'Health check updated.'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 69d385445..f9ff54fd0 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -303,6 +303,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } private function health_check() { + if ($this->application->isHealthcheckDisabled()) { + $this->newVersionIsHealthy = true; + return; + } ray('New container name: ', $this->container_name); if ($this->container_name) { $counter = 0; @@ -573,6 +577,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted ] ] ]; + if ($this->application->isHealthcheckDisabled()) { + data_forget($docker_compose, 'services.' . $this->container_name . '.healthcheck'); + } if (count($this->application->ports_mappings_array) > 0 && $this->pull_request_id === 0) { $docker_compose['services'][$this->container_name]['ports'] = $this->application->ports_mappings_array; } diff --git a/app/Models/Application.php b/app/Models/Application.php index 59b67fa16..224b332cc 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -231,4 +231,12 @@ class Application extends BaseModel } return true; } + public function isHealthcheckDisabled(): bool + { + if (data_get($this, 'dockerfile') || data_get($this, 'build_pack') === 'dockerfile' || data_get($this,'health_check_enabled') === false) { + ray('dockerfile'); + return true; + } + return false; + } } diff --git a/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php b/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php new file mode 100644 index 000000000..4b8eeea08 --- /dev/null +++ b/database/migrations/2023_09_23_111815_add_healthcheck_disable_to_apps_table.php @@ -0,0 +1,28 @@ +boolean('health_check_enabled')->default(true); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('applications', function (Blueprint $table) { + $table->dropColumn('health_check_enabled'); + }); + } +}; diff --git a/resources/views/livewire/project/shared/health-checks.blade.php b/resources/views/livewire/project/shared/health-checks.blade.php index c5596d311..e2ae8879e 100644 --- a/resources/views/livewire/project/shared/health-checks.blade.php +++ b/resources/views/livewire/project/shared/health-checks.blade.php @@ -5,24 +5,27 @@
Define how your resource's health should be checked.
-
- +
+ +
+
+ - - - - + + + + +
+
+ + +
+
+ + + + +
-
- - -
-
- - - - -
-
From 7d06fc44039a727a5366f6af79078884a5019703 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 1 Oct 2023 18:14:24 +0200 Subject: [PATCH 3/3] fix: do not show subscription cancelled noti --- routes/webhooks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/webhooks.php b/routes/webhooks.php index 2abba2c4d..d2857c75e 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -327,7 +327,7 @@ Route::post('/payments/stripe/events', function () { } if ($alreadyCancelAtPeriodEnd !== $cancelAtPeriodEnd) { if ($cancelAtPeriodEnd) { - send_internal_notification('Subscription cancelled at period end for team: ' . $subscription->team->id); + // send_internal_notification('Subscription cancelled at period end for team: ' . $subscription->team->id); } else { send_internal_notification('Subscription resumed for team: ' . $subscription->team->id); } @@ -346,7 +346,7 @@ Route::post('/payments/stripe/events', function () { 'stripe_invoice_paid' => false, 'stripe_trial_already_ended' => true, ]); - send_internal_notification('Subscription cancelled: ' . $subscription->team->id); + // send_internal_notification('Subscription cancelled: ' . $subscription->team->id); break; case 'customer.subscription.trial_will_end': $customerId = data_get($data, 'customer');