diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 15:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 15:09:16 +0300 |
commit | 0254867cf0f3341fd63cc6da07290f1da91f99ef (patch) | |
tree | 4b3fb556c1cb8cde3459e56d58d5e61eb268d9ec /app/models | |
parent | c417764f00abaa5d2224a50b8d43a15e40ef8790 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/alert_management/alert.rb | 2 | ||||
-rw-r--r-- | app/models/audit_event.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/cluster.rb | 52 | ||||
-rw-r--r-- | app/models/system_note_metadata.rb | 2 |
4 files changed, 7 insertions, 51 deletions
diff --git a/app/models/alert_management/alert.rb b/app/models/alert_management/alert.rb index 482531199d4..0af261a9358 100644 --- a/app/models/alert_management/alert.rb +++ b/app/models/alert_management/alert.rb @@ -135,6 +135,8 @@ module AlertManagement scope :counts_by_status, -> { group(:status).count } scope :counts_by_project_id, -> { group(:project_id).count } + alias_method :state, :status_name + def self.sort_by_attribute(method) case method.to_s when 'started_at_asc' then order_start_time(:asc) diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb index 530244a177c..3528892cd66 100644 --- a/app/models/audit_event.rb +++ b/app/models/audit_event.rb @@ -52,7 +52,7 @@ class AuditEvent < ApplicationRecord private def default_author_value - ::Gitlab::Audit::NullAuthor.for(author_id, details[:author_name]) + ::Gitlab::Audit::NullAuthor.for(author_id, (self[:author_name] || details[:author_name])) end end diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index bde7a2104ba..bfa97425dbb 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -228,7 +228,9 @@ module Clusters def calculate_reactive_cache return unless enabled? - { connection_status: retrieve_connection_status, nodes: retrieve_nodes } + gitlab_kubernetes_nodes = Gitlab::Kubernetes::Node.new(self) + + { connection_status: retrieve_connection_status, nodes: gitlab_kubernetes_nodes.all.presence } end def persisted_applications @@ -383,54 +385,6 @@ module Clusters result[:status] end - def retrieve_nodes - result = ::Gitlab::Kubernetes::KubeClient.graceful_request(id) { kubeclient.get_nodes } - - return unless result[:response] - - cluster_nodes = result[:response] - - result = ::Gitlab::Kubernetes::KubeClient.graceful_request(id) { kubeclient.metrics_client.get_nodes } - nodes_metrics = result[:response].to_a - - cluster_nodes.inject([]) do |memo, node| - sliced_node = filter_relevant_node_attributes(node) - - matched_node_metric = nodes_metrics.find { |node_metric| node_metric.metadata.name == node.metadata.name } - - sliced_node_metrics = matched_node_metric ? filter_relevant_node_metrics_attributes(matched_node_metric) : {} - - memo << sliced_node.merge(sliced_node_metrics) - end - end - - def filter_relevant_node_attributes(node) - { - 'metadata' => { - 'name' => node.metadata.name - }, - 'status' => { - 'capacity' => { - 'cpu' => node.status.capacity.cpu, - 'memory' => node.status.capacity.memory - }, - 'allocatable' => { - 'cpu' => node.status.allocatable.cpu, - 'memory' => node.status.allocatable.memory - } - } - } - end - - def filter_relevant_node_metrics_attributes(node_metrics) - { - 'usage' => { - 'cpu' => node_metrics.usage.cpu, - 'memory' => node_metrics.usage.memory - } - } - end - # To keep backward compatibility with AUTO_DEVOPS_DOMAIN # environment variable, we need to ensure KUBE_INGRESS_BASE_DOMAIN # is set if AUTO_DEVOPS_DOMAIN is set on any of the following options: diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb index 3f960af24d5..48b5565b350 100644 --- a/app/models/system_note_metadata.rb +++ b/app/models/system_note_metadata.rb @@ -18,7 +18,7 @@ class SystemNoteMetadata < ApplicationRecord designs_added designs_modified designs_removed designs_discussion_added title time_tracking branch milestone discussion task moved opened closed merged duplicate locked unlocked outdated - tag due_date pinned_embed cherry_pick health_status approved + tag due_date pinned_embed cherry_pick health_status approved unapproved ].freeze validates :note, presence: true |