Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 44,761
    • Issues 44,761
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,330
    • Merge requests 1,330
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #31475
Closed
Open
Issue created Jun 22, 2019 by Thong Kuah@tkuah5️⃣Maintainer

MergeRequestsController#ci_environment_status is making HTTP calls to Kubernetes

originally raised in https://gitlab.com/gitlab-org/gitlab-ce/issues/63475#note_183983111, thanks @dosuken123 !

This issue I think is taking up Unicorn workers which is not good

https://dashboards.gitlab.net/d/thYzurImk/rails-controllers?orgId=1&var-action=Projects::MergeRequestsController%23ci_environments_status.json&var-database=influxdb-01-inf-gprd&from=1560716181433&to=1560738261981&fullscreen&panelId=17

screenshot_4

This is called from deployment.has_metrics? - which executes HTTP request to a cluster for the number of environments https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/models/clusters/applications/prometheus.rb#L81. It's sequential operation and takes a long time to finish.

Call stack:

  • app/serializers/environment_status_entity.rb:14:in `block in class:EnvironmentStatusEntity'
  • app/models/deployment.rb:182:in `has_metrics?'
  • app/models/concerns/prometheus_adapter.rb:24:in `can_query?'
  • app/models/clusters/applications/prometheus.rb:82:in `prometheus_client'

Use the following failing spec:

diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 34cbf0c8723..99637cd743a 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -835,6 +835,13 @@ def post_assign_issues
         create(:merge_request, source_project: forked, target_project: project, target_branch: 'master', head_pipeline: pipeline)
       end
 
+      it 'does not make HTTP calls' do
+        cluster = create(:cluster, :provided_by_gcp, projects: [forked])
+        create(:clusters_applications_prometheus, :installed, cluster: cluster)
+
+        get_ci_environments_status
+      end
+
       it 'links to the environment on that project' do
         get_ci_environments_status
 

There are two variants of Prometheus - PrometheusService and Clusters::Application::Prometheus. It seems, PrometheusService doesn't need to perform any network calls compared to Clusters::Application::Prometheus

Edited Jun 22, 2019 by Thong Kuah
Assignee
Assign to
Time tracking