summaryrefslogtreecommitdiff
path: root/app/services/deployments
diff options
context:
space:
mode:
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