diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 00:09:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 00:09:04 +0000 |
commit | 27a18afc7dba4e09a5ec78e5c251c31216d7792a (patch) | |
tree | 5dcc015be79e00de4133a66defe10bf1463ff827 /app | |
parent | 71c9d577ad563572050335dc261ba7673e3e566f (diff) | |
download | gitlab-ce-27a18afc7dba4e09a5ec78e5c251c31216d7792a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
4 files changed, 50 insertions, 23 deletions
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index ae720065387..444368d0ef3 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -92,7 +92,10 @@ module Clusters def calculate_reactive_cache_for(environment) return unless enabled? - { pods: read_pods(environment.deployment_namespace) } + pods = read_pods(environment.deployment_namespace) + + # extract_relevant_pod_data avoids uploading all the pod info into ReactiveCaching + { pods: extract_relevant_pod_data(pods) } end def terminals(environment, data) @@ -203,6 +206,21 @@ module Clusters def nullify_blank_namespace self.namespace = nil if namespace.blank? end + + def extract_relevant_pod_data(pods) + pods.map do |pod| + { + 'metadata' => pod.fetch('metadata', {}) + .slice('name', 'generateName', 'labels', 'annotations', 'creationTimestamp'), + 'status' => pod.fetch('status', {}).slice('phase'), + 'spec' => { + 'containers' => pod.fetch('spec', {}) + .fetch('containers', []) + .map { |c| c.slice('name') } + } + } + end + end end end end diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 5ee6522fb9d..88a2531d649 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -128,10 +128,6 @@ module ErrorTracking end end - def expire_issues_cache - Rails.cache.delete_matched(expand_cache_key('list_issues')) - end - # http://HOST/api/0/projects/ORG/PROJECT # -> # http://HOST/ORG/PROJECT @@ -148,12 +144,6 @@ module ErrorTracking private - def expand_cache_key(resource_prefix) - klass_key = self.class.reactive_cache_key.call(self).join(':') - - "#{klass_key}:#{resource_prefix}*" - end - def add_gitlab_issue_details(issue) issue.gitlab_commit = match_gitlab_commit(issue.first_release_version) issue.gitlab_commit_path = project_commit_path(project, issue.gitlab_commit) if issue.gitlab_commit diff --git a/app/services/error_tracking/issue_details_service.rb b/app/services/error_tracking/issue_details_service.rb index ee6d556518b..0068a9e9b6d 100644 --- a/app/services/error_tracking/issue_details_service.rb +++ b/app/services/error_tracking/issue_details_service.rb @@ -2,12 +2,35 @@ module ErrorTracking class IssueDetailsService < ErrorTracking::BaseService + include Gitlab::Routing + include Gitlab::Utils::StrongMemoize + private def perform response = project_error_tracking_setting.issue_details(issue_id: params[:issue_id]) - compose_response(response) + compose_response(response) do + # The gitlab_issue attribute can contain an absolute GitLab url from the Sentry Client + # here we overwrite that in favor of our own data if we have it + response[:issue].gitlab_issue = gitlab_issue_url if gitlab_issue_url + end + end + + def gitlab_issue_url + strong_memoize(:gitlab_issue_url) do + # Use the absolute url to match the GitLab issue url that the Sentry api provides + project_issue_url(project, gitlab_issue.iid) if gitlab_issue + end + end + + def gitlab_issue + strong_memoize(:gitlab_issue) do + SentryIssueFinder + .new(project, current_user: current_user) + .execute(params[:issue_id]) + &.issue + end end def parse_response(response) diff --git a/app/services/error_tracking/issue_update_service.rb b/app/services/error_tracking/issue_update_service.rb index 904aed27684..e516ac95138 100644 --- a/app/services/error_tracking/issue_update_service.rb +++ b/app/services/error_tracking/issue_update_service.rb @@ -2,8 +2,6 @@ module ErrorTracking class IssueUpdateService < ErrorTracking::BaseService - include ::Gitlab::Utils::StrongMemoize - private def perform @@ -14,14 +12,14 @@ module ErrorTracking compose_response(response) do response[:closed_issue_iid] = update_related_issue&.iid - project_error_tracking_setting.expire_issues_cache end end def update_related_issue - return if related_issue.nil? + issue = related_issue + return unless issue - close_and_create_note(related_issue) + close_and_create_note(issue) end def close_and_create_note(issue) @@ -45,12 +43,10 @@ module ErrorTracking end def related_issue - strong_memoize(:related_issue) do - SentryIssueFinder - .new(project, current_user: current_user) - .execute(params[:issue_id]) - &.issue - end + SentryIssueFinder + .new(project, current_user: current_user) + .execute(params[:issue_id]) + &.issue end def resolving? |