diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 21:08:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 21:08:07 +0300 |
commit | 2c72daf2f1744f2b8c8c6674c266907e9ef55558 (patch) | |
tree | e489b6e87557d3f6d8a94f2e7d4d47e633d646b5 /app/services/pages_domains | |
parent | 4e9acbfba3682c552b3de707c535e6257ef41054 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/pages_domains')
-rw-r--r-- | app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb b/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb index 58f795e639e..93445dd4ddd 100644 --- a/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb +++ b/app/services/pages_domains/obtain_lets_encrypt_certificate_service.rb @@ -36,8 +36,8 @@ module PagesDomains when 'valid' save_certificate(acme_order.private_key, api_order) acme_order.destroy! - # when 'invalid' - # TODO: implement error handling + when 'invalid' + save_order_error(acme_order, api_order) end end @@ -47,5 +47,28 @@ module PagesDomains certificate = api_order.certificate pages_domain.update!(gitlab_provided_key: private_key, gitlab_provided_certificate: certificate) end + + def save_order_error(acme_order, api_order) + log_error(api_order) + + return unless Feature.enabled?(:pages_letsencrypt_errors, pages_domain.project) + + pages_domain.assign_attributes(auto_ssl_failed: true) + pages_domain.save!(validate: false) + + acme_order.destroy! + end + + def log_error(api_order) + Gitlab::AppLogger.error( + message: "Failed to obtain Let's Encrypt certificate", + acme_error: api_order.challenge_error, + project_id: pages_domain.project_id, + pages_domain: pages_domain.domain + ) + rescue => e + # getting authorizations is an additional network request which can raise errors + Gitlab::ErrorTracking.track_exception(e) + end end end |