diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-11-23 16:17:17 +0100 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-11-27 15:23:02 +0100 |
commit | 7e7fb6deba4e58b4dbbb21a8e859327cebd109d1 (patch) | |
tree | 1aab6917825b0eb7da1a6e8b35f136bfae26dafe /app/services/clusters/applications | |
parent | 629b1e6b17d3db2c4f9e3b1405796767440e6bcb (diff) | |
download | gitlab-ce-7e7fb6deba4e58b4dbbb21a8e859327cebd109d1.tar.gz |
Use JSON logging for helm install services
Diffstat (limited to 'app/services/clusters/applications')
3 files changed, 22 insertions, 6 deletions
diff --git a/app/services/clusters/applications/base_helm_service.rb b/app/services/clusters/applications/base_helm_service.rb index 270a8eb24f4..e86ca8cf1d0 100644 --- a/app/services/clusters/applications/base_helm_service.rb +++ b/app/services/clusters/applications/base_helm_service.rb @@ -11,6 +11,25 @@ module Clusters protected + def log_error(error) + meta = { + exception: error.class.name, + error_code: error.respond_to?(:error_code) ? error.error_code : nil, + service: self.class.name, + app_id: app.id, + project_ids: app.cluster.project_ids, + group_ids: app.cluster.group_ids, + message: error.message + } + + logger.error(meta) + Gitlab::Sentry.track_acceptable_exception(error, extra: meta) + end + + def logger + @logger ||= Gitlab::Kubernetes::Logger.build + end + def cluster app.cluster end diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb index ca0f7b30053..0e094c6ae1a 100644 --- a/app/services/clusters/applications/check_installation_progress_service.rb +++ b/app/services/clusters/applications/check_installation_progress_service.rb @@ -15,8 +15,7 @@ module Clusters check_timeout end rescue Kubeclient::HttpError => e - Rails.logger.error("Kubernetes error: #{e.error_code} #{e.message}") - Gitlab::Sentry.track_acceptable_exception(e, extra: { scope: 'kubernetes', app_id: app.id }) + log_error(e) app.make_errored!("Kubernetes error: #{e.error_code}") unless app.errored? end diff --git a/app/services/clusters/applications/install_service.rb b/app/services/clusters/applications/install_service.rb index f4385748c43..5a65dc4ef59 100644 --- a/app/services/clusters/applications/install_service.rb +++ b/app/services/clusters/applications/install_service.rb @@ -13,12 +13,10 @@ module Clusters ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) rescue Kubeclient::HttpError => e - Rails.logger.error("Kubernetes error: #{e.error_code} #{e.message}") - Gitlab::Sentry.track_acceptable_exception(e, extra: { scope: 'kubernetes', app_id: app.id }) + log_error(e) app.make_errored!("Kubernetes error: #{e.error_code}") rescue StandardError => e - Rails.logger.error "Can't start installation process: #{e.class.name} #{e.message}" - Gitlab::Sentry.track_acceptable_exception(e, extra: { scope: 'kubernetes', app_id: app.id }) + log_error(e) app.make_errored!("Can't start installation process.") end end |