From dc1cd5fb654ae69365ba2b66f2d25ff076b291ed Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Tue, 7 Jul 2020 19:15:50 +0000 Subject: [PATCH 1/2] Container project dashboard - add missing dataAvailable otherwise, the dashboard doesn't display anything, because loadingDone is true (no spinner), dataAvailable is not false (no empty message), or true (no chart) --- app/services/container_service_mixin.rb | 5 +++++ app/services/dashboard_service.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/app/services/container_service_mixin.rb b/app/services/container_service_mixin.rb index 26794970ed3..285bf194a47 100644 --- a/app/services/container_service_mixin.rb +++ b/app/services/container_service_mixin.rb @@ -50,6 +50,7 @@ def hourly_pod_metrics def create_delete_data(create_trend, delete_trend) if create_trend.any? { + :dataAvailable => true, :xData => create_trend.keys, :yCreated => create_trend.values.map(&:round), :yDeleted => delete_trend.values.map(&:round) @@ -71,6 +72,7 @@ def utilization_data(used_cpu, total_cpu, used_mem, total_mem) def trend_data(trend) if trend.any? { + :dataAvailable => true, :xData => trend.keys, :yData => trend.values.map { |value| (value || 0).round } } @@ -154,6 +156,7 @@ def realtime_utilization if used_cpu.any? { + :dataAvailable => true, :interval_name => "realtime", :xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem) } @@ -173,6 +176,7 @@ def hourly_utilization if used_cpu.any? { + :dataAvailable => true, :interval_name => "hourly", :xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem) } @@ -192,6 +196,7 @@ def daily_utilization if used_cpu.any? { + :dataAvailable => true, :interval_name => "daily", :xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem) } diff --git a/app/services/dashboard_service.rb b/app/services/dashboard_service.rb index 03df4842246..bcaadf1464e 100644 --- a/app/services/dashboard_service.rb +++ b/app/services/dashboard_service.rb @@ -16,6 +16,7 @@ def format_utilization_data(used_cpu, used_mem, total_cpu, total_mem) def format_cpu(used, total) { + :dataAvailable => true, :used => cpu_num(used.values.last).round(display_precision), :total => cpu_num(total.values.last).round(0), :xData => used.keys, @@ -29,6 +30,7 @@ def cpu_num(val) def format_memory(used, total) { + :dataAvailable => true, :used => mem_num(used.values.last).round(display_precision), :total => mem_num(total.values.last).round(0), :xData => used.keys, From 030d7c17a3d150b8ebac4d0dc61b0f4f9fafa03f Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Wed, 8 Jul 2020 11:05:02 +0000 Subject: [PATCH 2/2] container dashboard service spec - expect dataAvailable true in more places --- spec/services/container_dashboard_service_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/services/container_dashboard_service_spec.rb b/spec/services/container_dashboard_service_spec.rb index 23f09f87ed6..6ef698b2bee 100644 --- a/spec/services/container_dashboard_service_spec.rb +++ b/spec/services/container_dashboard_service_spec.rb @@ -77,12 +77,14 @@ expect(node_utilization_single_provider).to eq( :cpu => { + :dataAvailable => true, :used => 2, :total => 2, :xData => [current_date], :yData => [2] }, :memory => { + :dataAvailable => true, :used => 1, :total => 2, :xData => [current_date], @@ -92,12 +94,14 @@ expect(node_utilization_all_providers).to eq( :cpu => { + :dataAvailable => true, :used => 3, :total => 3, :xData => [current_date], :yData => [3.0] }, :memory => { + :dataAvailable => true, :used => 2, :total => 3, :xData => [current_date], @@ -382,11 +386,13 @@ daily_network_trends_single_provider = described_class.new(ems_openshift.id, controller).network_metrics[:xy_data] expect(daily_network_trends_single_provider).to eq( + :dataAvailable => true, :xData => [previous_date, current_date], :yData => [2000, 1000] ) expect(daily_network_trends).to eq( + :dataAvailable => true, :xData => [previous_date, current_date], :yData => [2000, 2500] ) @@ -443,15 +449,16 @@ ems_kubernetes.metric_rollups << nil_fields_metric.dup hourly_network_trends = described_class.new(nil, controller).network_metrics[:xy_data] - hourly_network_trends_single_provider = - described_class.new(ems_openshift.id, controller).network_metrics[:xy_data] + hourly_network_trends_single_provider = described_class.new(ems_openshift.id, controller).network_metrics[:xy_data] expect(hourly_network_trends_single_provider).to eq( + :dataAvailable => true, :xData => [previous_date.beginning_of_hour.utc, current_date.beginning_of_hour.utc], :yData => [2000, 1000] ) expect(hourly_network_trends).to eq( + :dataAvailable => true, :xData => [previous_date.beginning_of_hour.utc, current_date.beginning_of_hour.utc], :yData => [2000, 2500] )