Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container trends chart - wait for loadingDone before displaying pf-trends-chart #5310

Merged
merged 1 commit into from
Mar 8, 2019
Merged

Container trends chart - wait for loadingDone before displaying pf-trends-chart #5310

merged 1 commit into from
Mar 8, 2019

Conversation

himdel
Copy link
Contributor

@himdel himdel commented Mar 6, 2019

Compute > Containers > Overview or Compute > Containers > Providers > pick one, dashboard view

This fixes a

    TypeError: Cannot read property 'layout' of undefined
    at trendsChartController.e.updateAll (application-d966831b…581bed47155710.js:3)
    at trendsChartController.e.$onChanges (application-d966831b…581bed47155710.js:3)

when the JSON endpoints are taking longer to respond. (Longer = angular manages to do the first render before any data arrives.)

The controller already has a concept of loadingDone, used to display a spinner.
But it was never used to prevent rendering of the pf-trends-chart component, which fails when config is undefined.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1684226

(related to but not the same problem as in #5232)

…ends-chart

prevents

    TypeError: Cannot read property 'layout' of undefined
    at trendsChartController.e.updateAll (application-d966831b…581bed47155710.js:3)
    at trendsChartController.e.$onChanges (application-d966831b…581bed47155710.js:3)

when the JSON endpoints are taking longer to respond.

The controller already has a concept of loadingDone, used to display a spinner.
But it was never used to prevent rendering of the pf-trends-chart component, which fails when config is undefined.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1684226
@himdel
Copy link
Contributor Author

himdel commented Mar 6, 2019

Testing:

diff --git a/app/controllers/container_dashboard_controller.rb b/app/controllers/container_dashboard_controller.rb
index 7cc34bf56..1a067ebce 100644
--- a/app/controllers/container_dashboard_controller.rb
+++ b/app/controllers/container_dashboard_controller.rb
@@ -20,29 +20,38 @@ class ContainerDashboardController < ApplicationController
     redirect_to(:action => 'show')
   end
 
+  def null
+    nil
+  end
+
   def data
-    return data_live if params[:live] == 'true'
-    render :json => {:data => collect_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"status":{"nodes":{"count":5,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_nodes"},"containers":{"count":19,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=containers"},"registries":{"count":2,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_image_registries"},"projects":{"count":15,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_projects"},"pods":{"count":18,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_groups"},"services":{"count":14,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_services"},"images":{"count":141,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_images"},"routes":{"count":5,"errorCount":0,"warningCount":0,"href":"https://10.8.197.218/ems_container/2?display=container_routes"}},"providers":[[{"count":1,"typeName":"Openshift","iconImage":"/assets/svg/vendor-openshift-c33e45a9f6f48fbdd99bbad7f827c328e32d8bf032d0b64c76e4511b6cd18ef3.svg","statusIcon":"pficon pficon-ok"}],null],"alerts":{"count":null,"href":"/alerts_overview/show","notifications":[{}],"dataAvailable":false}}}
   end
 
   def heatmaps_data
-    render :json => {:data => collect_heatmaps_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"heatmaps":{"nodeCpuUsage":[{"id":5,"node":"env-ocp-compute1-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"Cores","total":4,"percent":0.07},{"id":6,"node":"env-ocp-compute2-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"Cores","total":4,"percent":0.02},{"id":7,"node":"env-ocp-compute3-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"Cores","total":1,"percent":0.04},{"id":8,"node":"env-ocp-infra-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"Cores","total":4,"percent":0.03},{"id":9,"node":"env-ocp-master-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"Cores","total":4,"percent":0.04}],"nodeMemoryUsage":[{"id":5,"node":"env-ocp-compute1-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"GB","total":11852,"percent":0.3},{"id":6,"node":"env-ocp-compute2-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"GB","total":11852,"percent":0.31},{"id":7,"node":"env-ocp-compute3-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"GB","total":11852,"percent":0.15},{"id":8,"node":"env-ocp-infra-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"GB","total":11852,"percent":0.44},{"id":9,"node":"env-ocp-master-v1.cmqe.lab.eng.rdu2.redhat.com","provider":"ocp-37-hawk","unit":"GB","total":15884,"percent":0.55}],"title":"Node Utilization"}}}
   end
 
   def ems_utilization_data
-    render :json => {:data => collect_ems_utilization_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"ems_utilization":{"interval_name":"daily","xy_data":{"cpu":{"used":1,"total":17,"xData":["2019-02-28T00:00:00.000Z","2019-03-01T00:00:00.000Z","2019-03-02T00:00:00.000Z","2019-03-03T00:00:00.000Z"],"yData":[0.7,0.7,0.7,0.7]},"memory":{"used":22,"total":62,"xData":["2019-02-28T00:00:00.000Z","2019-03-01T00:00:00.000Z","2019-03-02T00:00:00.000Z","2019-03-03T00:00:00.000Z"],"yData":[22.35,22.32,22.38,22.45]}}}}}
   end
 
   def network_metrics_data
-    render :json => {:data => collect_network_metrics_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"network_metrics":{"dataAvailable":true,"interval_name":"daily","xy_data":{"xData":["2019-02-28T00:00:00.000Z","2019-03-01T00:00:00.000Z","2019-03-02T00:00:00.000Z","2019-03-03T00:00:00.000Z"],"yData":[745,692,684,694]}}}}
   end
 
   def pod_metrics_data
-    render :json => {:data => collect_pod_metrics_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"pod_metrics":{"dataAvailable":true,"interval_name":"daily","xy_data":{"xData":["2019-02-28T00:00:00.000Z","2019-03-01T00:00:00.000Z","2019-03-02T00:00:00.000Z","2019-03-03T00:00:00.000Z"],"yCreated":[0,0,0,0],"yDeleted":[0,0,0,0]}}}}
   end
 
   def image_metrics_data
-    render :json => {:data => collect_image_metrics_data(params[:id])}
+    sleep(rand * 6) + 2
+    render :json => {"data":{"image_metrics":{"dataAvailable":true,"interval_name":"daily","xy_data":{"xData":["2019-02-28T00:00:00.000Z","2019-03-01T00:00:00.000Z","2019-03-02T00:00:00.000Z","2019-03-03T00:00:00.000Z"],"yData":[0,0,0,0]}}}}
   end
 
   def data_live

(the data comes from the appliance provided in the BZ, but it looks like those sleep are what's really important to reproduce the bug)

@miq-bot
Copy link
Member

miq-bot commented Mar 6, 2019

Checked commit https://github.com/himdel/manageiq-ui-classic/commit/8e3a5f476a3f6a8bd11344affac3b3a5f344d918 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Haml - Linter::Haml STDERR:
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.6-compliant syntax, but you are running 2.3.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

@mzazrivec mzazrivec self-assigned this Mar 8, 2019
@mzazrivec mzazrivec added this to the Sprint 107 Ending Mar 18, 2019 milestone Mar 8, 2019
@mzazrivec mzazrivec merged commit 1267378 into ManageIQ:master Mar 8, 2019
@himdel himdel deleted the bz1684226-netowkr-trends branch March 11, 2019 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants