summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-06-24 14:08:42 +1200
committerThong Kuah <tkuah@gitlab.com>2019-06-27 17:28:52 +1200
commit04af6132b14e594aeddef2a6d0c171af667c9539 (patch)
tree774a42379216c745f8f7e36529b22e48dc17717e /app/models
parent4615dca1d90975d16b1534292c1b2886da1b2cd5 (diff)
downloadgitlab-ce-04af6132b14e594aeddef2a6d0c171af667c9539.tar.gz
Use #cluster for prometheus_adapteradd-clusters-to-deployment
We still fallback to environment.deployment_platform until we can backfill
Diffstat (limited to 'app/models')
-rw-r--r--app/models/deployment.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 8332656a7a6..a8f5642f726 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -197,7 +197,22 @@ class Deployment < ApplicationRecord
private
def prometheus_adapter
- environment.prometheus_adapter
+ service = project.find_or_initialize_service('prometheus')
+
+ if service.can_query?
+ service
+ else
+ cluster_prometheus
+ end
+ end
+
+ # TODO remove fallback case to deployment_platform_cluster.
+ # Otherwise we will continue to pay the performance penalty described in
+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/63475
+ def cluster_prometheus
+ cluster_with_fallback = cluster || deployment_platform_cluster
+
+ cluster_with_fallback.application_prometheus if cluster_with_fallback&.application_prometheus_available?
end
def ref_path