From b56c7c34cbbe8bf406f482bb64fb0fbaa43bf526 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 29 Jan 2024 12:51:20 +0100 Subject: [PATCH] fix: unhealthy deployments should be failed --- app/Jobs/ApplicationDeploymentJob.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 4aa4a898a..7e8d8a756 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -262,10 +262,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } $this->application->isConfigurationChanged(true); } catch (Exception $e) { - if ($this->pull_request_id !== 0) { - if ($this->application->is_github_based()) { - ApplicationPullRequestUpdateJob::dispatch(application: $this->application, preview: $this->preview, deployment_uuid: $this->deployment_uuid, status: ProcessStatus::ERROR); - } + if ($this->pull_request_id !== 0 && $this->application->is_github_based()) { + ApplicationPullRequestUpdateJob::dispatch(application: $this->application, preview: $this->preview, deployment_uuid: $this->deployment_uuid, status: ProcessStatus::ERROR); } ray($e); $this->fail($e); @@ -691,7 +689,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted if ($this->full_healthcheck_url) { $this->application_deployment_queue->addLogEntry("Healthcheck URL (inside the container): {$this->full_healthcheck_url}"); } - while ($counter < $this->application->health_check_retries) { + while ($counter <= $this->application->health_check_retries) { $this->execute_remote_command( [ "docker inspect --format='{{json .State.Health.Status}}' {$this->container_name}", @@ -1504,13 +1502,13 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); private function next(string $status) { + queue_next_deployment($this->application); // If the deployment is cancelled by the user, don't update the status - if ($this->application_deployment_queue->status !== ApplicationDeploymentStatus::CANCELLED_BY_USER->value) { + if ($this->application_deployment_queue->status !== ApplicationDeploymentStatus::CANCELLED_BY_USER->value && $this->application_deployment_queue->status !== ApplicationDeploymentStatus::FAILED->value) { $this->application_deployment_queue->update([ 'status' => $status, ]); } - queue_next_deployment($this->application); if ($status === ApplicationDeploymentStatus::FINISHED->value) { $this->application->environment->project->team?->notify(new DeploymentSuccess($this->application, $this->deployment_uuid, $this->preview)); }