summaryrefslogtreecommitdiff
path: root/app/services/deployments
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /app/services/deployments
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/services/deployments')
-rw-r--r--app/services/deployments/update_environment_service.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/services/deployments/update_environment_service.rb b/app/services/deployments/update_environment_service.rb
index 9e862d6fa52..6f85779c285 100644
--- a/app/services/deployments/update_environment_service.rb
+++ b/app/services/deployments/update_environment_service.rb
@@ -9,6 +9,8 @@ module Deployments
delegate :variables, to: :deployable
delegate :options, to: :deployable, allow_nil: true
+ EnvironmentUpdateFailure = Class.new(StandardError)
+
def initialize(deployment)
@deployment = deployment
@deployable = deployment.deployable
@@ -31,8 +33,18 @@ module Deployments
renew_deployment_tier
environment.fire_state_event(action)
- if environment.save && !environment.stopped?
- deployment.update_merge_request_metrics!
+ if environment.save
+ deployment.update_merge_request_metrics! unless environment.stopped?
+ else
+ # If there is a validation error on environment update, such as
+ # the external URL is malformed, the error message is recorded for debugging purpose.
+ # We should surface the error message to users for letting them to take an action.
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/21182.
+ Gitlab::ErrorTracking.track_exception(
+ EnvironmentUpdateFailure.new,
+ project_id: deployment.project_id,
+ environment_id: environment.id,
+ reason: environment.errors.full_messages.to_sentence)
end
end
end