From 09aef7fd36b3730b73e6ede6ee7f657289d3d734 Mon Sep 17 00:00:00 2001 From: Rajendra Kadam <rkadam@gitlab.com> Date: Fri, 28 Jul 2023 11:18:56 +0000 Subject: [PATCH] Delete pod dashboard service class and usages --- .../dashboard/pod_dashboard_service.rb | 36 ------ config/prometheus/pod_metrics.yml | 115 ------------------ lib/gitlab/metrics/dashboard/finder.rb | 1 - .../metrics/dashboard/service_selector.rb | 1 - locale/gitlab.pot | 3 - .../gitlab/metrics/dashboard/finder_spec.rb | 5 +- .../dashboard/service_selector_spec.rb | 6 - .../dashboard/pod_dashboard_service_spec.rb | 74 ----------- .../helpers/metrics_dashboard_helpers.rb | 4 - 9 files changed, 2 insertions(+), 243 deletions(-) delete mode 100644 app/services/metrics/dashboard/pod_dashboard_service.rb delete mode 100644 config/prometheus/pod_metrics.yml delete mode 100644 spec/services/metrics/dashboard/pod_dashboard_service_spec.rb diff --git a/app/services/metrics/dashboard/pod_dashboard_service.rb b/app/services/metrics/dashboard/pod_dashboard_service.rb deleted file mode 100644 index e2d7a081a3e9..000000000000 --- a/app/services/metrics/dashboard/pod_dashboard_service.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -module Metrics - module Dashboard - class PodDashboardService < ::Metrics::Dashboard::PredefinedDashboardService - DASHBOARD_PATH = 'config/prometheus/pod_metrics.yml' - DASHBOARD_NAME = N_('K8s pod health') - - # SHA256 hash of dashboard content - DASHBOARD_VERSION = '3a91b32f91b2dd3d90275333c0ea3630b3f3f37c4296ede5b5eef59bf523d66b' - - SEQUENCE = [ - STAGES::VariableEndpointInserter, - STAGES::PanelIdsInserter - ].freeze - - class << self - def all_dashboard_paths(_project) - [{ - path: DASHBOARD_PATH, - display_name: _(DASHBOARD_NAME), - default: false, - system_dashboard: false, - out_of_the_box_dashboard: out_of_the_box_dashboard? - }] - end - end - - private - - def dashboard_version - DASHBOARD_VERSION - end - end - end -end diff --git a/config/prometheus/pod_metrics.yml b/config/prometheus/pod_metrics.yml deleted file mode 100644 index b93951244056..000000000000 --- a/config/prometheus/pod_metrics.yml +++ /dev/null @@ -1,115 +0,0 @@ -dashboard: 'K8s pod health' -priority: 2 - -templating: - variables: - pod: - label: 'Pod name' - type: metric_label_values - options: - series_selector: 'container_memory_working_set_bytes' - label: 'pod' - -panel_groups: -- group: CPU metrics - panels: - - title: "CPU usage" - type: "line-chart" - y_label: "Cores per container" - metrics: - - id: pod_cpu_usage_seconds_total - query_range: >- - sum( - rate(container_cpu_usage_seconds_total{pod="{{pod}}",container!="POD"}[5m]) - ) - by (container) - unit: "cores" - label: container - - - title: "CPU throttling" - type: "line-chart" - y_label: "Cores per container" - metrics: - - id: pod_cpu_cfs_throttle - query_range: >- - sum( - rate(container_cpu_cfs_throttled_seconds_total{pod="{{pod}}"}[5m]) - ) - by (container) - unit: "cores" - label: container - -- group: Memory metrics - panels: - - title: "Memory usage working set" - type: "line-chart" - y_label: "Working set memory" - metrics: - - id: pod_memory_working_set - query_range: >- - sum( - container_memory_working_set_bytes{pod="{{pod}}",container!="POD"} - ) by (container) - unit: "bytes" - label: container - -- group: Network metrics - panels: - - title: "Network Receive (In)" - type: "line-chart" - y_label: "Received (bytes/sec)" - metrics: - - id: pod_network_receive - query_range: >- - sum( - rate( - container_network_receive_bytes_total{pod="{{pod}}"}[5m] - ) - ) by (pod) - unit: "bytes" - label: pod - - - title: "Network Transmit (Out)" - type: "line-chart" - y_label: "Transmitted (bytes/sec)" - metrics: - - id: pod_network_transmit - query_range: >- - sum( - rate( - container_network_transmit_bytes_total{pod="{{pod}}"}[5m] - ) - ) by (pod) - unit: bytes - label: pod - -- group: Disk metrics - panels: - - title: "Disk Reads" - type: "line-chart" - y_label: "Disk reads (bytes/sec)" - metrics: - - id: pod_disk_reads - query_range: >- - sum( - rate( - container_fs_reads_bytes_total{pod="{{pod}}", container!="POD"}[5m] - ) - ) by (container,device) - - unit: "bytes / sec" - label: "{{container}} {{device}}" - - - title: "Disk Writes" - type: "line-chart" - y_label: "Disk writes (bytes/sec)" - metrics: - - id: pod_disk_writes - query_range: >- - sum( - rate( - container_fs_writes_bytes_total{pod="{{pod}}", container!="POD"}[5m] - ) - ) by (container,device) - unit: "bytes / sec" - label: "{{container}} {{device}}" diff --git a/lib/gitlab/metrics/dashboard/finder.rb b/lib/gitlab/metrics/dashboard/finder.rb index 12f7c347b2d7..5bc440734a85 100644 --- a/lib/gitlab/metrics/dashboard/finder.rb +++ b/lib/gitlab/metrics/dashboard/finder.rb @@ -8,7 +8,6 @@ module Metrics module Dashboard class Finder PREDEFINED_DASHBOARD_LIST = [ - ::Metrics::Dashboard::PodDashboardService, ::Metrics::Dashboard::SystemDashboardService ].freeze diff --git a/lib/gitlab/metrics/dashboard/service_selector.rb b/lib/gitlab/metrics/dashboard/service_selector.rb index 67bf4ce7e9a1..a016f97d2c3d 100644 --- a/lib/gitlab/metrics/dashboard/service_selector.rb +++ b/lib/gitlab/metrics/dashboard/service_selector.rb @@ -22,7 +22,6 @@ class << self ::Metrics::Dashboard::DynamicEmbedService, ::Metrics::Dashboard::DefaultEmbedService, ::Metrics::Dashboard::SystemDashboardService, - ::Metrics::Dashboard::PodDashboardService, ::Metrics::Dashboard::CustomDashboardService ].freeze diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7708473064ff..26f9c92e1b08 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -26782,9 +26782,6 @@ msgstr "" msgid "Just me" msgstr "" -msgid "K8s pod health" -msgstr "" - msgid "KEY" msgstr "" diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb index ce114e9413fc..991f8eff684a 100644 --- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb @@ -130,10 +130,9 @@ describe '.find_all_paths' do let(:all_dashboard_paths) { described_class.find_all_paths(project) } let(:system_dashboard) { { path: system_dashboard_path, display_name: 'Overview', default: true, system_dashboard: true, out_of_the_box_dashboard: true } } - let(:k8s_pod_health_dashboard) { { path: pod_dashboard_path, display_name: 'K8s pod health', default: false, system_dashboard: false, out_of_the_box_dashboard: true } } it 'includes OOTB dashboards by default' do - expect(all_dashboard_paths).to eq([k8s_pod_health_dashboard, system_dashboard]) + expect(all_dashboard_paths).to eq([system_dashboard]) end context 'when the project contains dashboards' do @@ -164,7 +163,7 @@ out_of_the_box_dashboard: false } - expect(all_dashboard_paths).to eq([project_dashboard2, k8s_pod_health_dashboard, project_dashboard1, system_dashboard]) + expect(all_dashboard_paths).to eq([project_dashboard2, project_dashboard1, system_dashboard]) end end end diff --git a/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb b/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb index 343596af5cf3..ae4cdbb86a73 100644 --- a/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb @@ -22,12 +22,6 @@ it { is_expected.to be Metrics::Dashboard::SystemDashboardService } end - - context 'when the path is for the pod dashboard' do - let(:arguments) { { dashboard_path: pod_dashboard_path } } - - it { is_expected.to be Metrics::Dashboard::PodDashboardService } - end end context 'when the embedded flag is provided' do diff --git a/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb b/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb deleted file mode 100644 index a6fcb6b4842b..000000000000 --- a/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_caching, - feature_category: :cell do - include MetricsDashboardHelpers - - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project) } - let_it_be(:environment) { create(:environment, project: project) } - - let(:dashboard_path) { described_class::DASHBOARD_PATH } - let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } - - before do - project.add_maintainer(user) - end - - subject { described_class.new(*service_params) } - - describe '#raw_dashboard' do - it_behaves_like '#raw_dashboard raises error if dashboard loading fails' - end - - describe '.valid_params?' do - let(:params) { { dashboard_path: described_class::DASHBOARD_PATH } } - - subject { described_class.valid_params?(params) } - - it { is_expected.to be_truthy } - - context 'missing dashboard_path' do - let(:params) { {} } - - it { is_expected.to be_falsey } - end - - context 'non-matching dashboard_path' do - let(:params) { { dashboard_path: 'path/to/bunk.yml' } } - - it { is_expected.to be_falsey } - end - end - - describe '#get_dashboard' do - let(:service_call) { subject.get_dashboard } - - it_behaves_like 'valid dashboard service response' - it_behaves_like 'caches the unprocessed dashboard for subsequent calls' - it_behaves_like 'refreshes cache when dashboard_version is changed' - it_behaves_like 'updates gitlab_metrics_dashboard_processing_time_ms metric' - - it_behaves_like 'dashboard_version contains SHA256 hash of dashboard file content' do - let(:dashboard_version) { subject.send(:dashboard_version) } - end - end - - describe '.all_dashboard_paths' do - it 'returns the dashboard attributes' do - all_dashboards = described_class.all_dashboard_paths(project) - - expect(all_dashboards).to eq( - [{ - path: described_class::DASHBOARD_PATH, - display_name: described_class::DASHBOARD_NAME, - default: false, - system_dashboard: false, - out_of_the_box_dashboard: true - }] - ) - end - end -end diff --git a/spec/support/helpers/metrics_dashboard_helpers.rb b/spec/support/helpers/metrics_dashboard_helpers.rb index 417baeda33a1..5fdff45e8003 100644 --- a/spec/support/helpers/metrics_dashboard_helpers.rb +++ b/spec/support/helpers/metrics_dashboard_helpers.rb @@ -42,10 +42,6 @@ def system_dashboard_path Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH end - def pod_dashboard_path - Metrics::Dashboard::PodDashboardService::DASHBOARD_PATH - end - def business_metric_title Enums::PrometheusMetric.group_details[:business][:group_title] end -- GitLab