diff options
author | Tiger <twatson@gitlab.com> | 2019-05-17 01:49:12 +0300 |
---|---|---|
committer | Tiger <twatson@gitlab.com> | 2019-05-21 19:38:11 +0300 |
commit | 101c4480b32044682e453753c6bb18c2a296b044 (patch) | |
tree | 46b6ac3df55c748a6854bdb5c02a696228a7e9fc /app/finders | |
parent | 0702d4b6899648ba12a747824f3db86c2f4aa42e (diff) |
Remove legacy Kubernetes #actual_namespace
When Kubernetes clusters were originally built they could only
exist at the project level, and so there was logic included
that assumed there would only ever be a single Kubernetes
namespace per cluster. We now support clusters at the group
and instance level, which allows multiple namespaces.
This change consolidates various project-specific fallbacks to
generate namespaces, and hands all responsibility to the
Clusters::KubernetesNamespace model. There is now no concept of
a single namespace for a Clusters::Platforms::Kubernetes; to
retrieve a namespace a project must now be supplied in all cases.
This simplifies upcoming work to use a separate Kubernetes
namespace per project environment (instead of a namespace
per project).
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/projects/serverless/functions_finder.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/finders/projects/serverless/functions_finder.rb b/app/finders/projects/serverless/functions_finder.rb index d9802598c64..e5bffccabfe 100644 --- a/app/finders/projects/serverless/functions_finder.rb +++ b/app/finders/projects/serverless/functions_finder.rb @@ -3,6 +3,8 @@ module Projects module Serverless class FunctionsFinder + attr_reader :project + def initialize(project) @clusters = project.clusters @project = project @@ -27,7 +29,7 @@ module Projects environment_scope == c.environment_scope end - func = ::Serverless::Function.new(@project, name, cluster.platform_kubernetes&.actual_namespace) + func = ::Serverless::Function.new(project, name, cluster.kubernetes_namespace_for(project)) prometheus_adapter.query(:knative_invocation, func) end @@ -43,7 +45,7 @@ module Projects clusters_with_knative_installed.preload_knative.map do |cluster| next if environment_scope != cluster.environment_scope - services = cluster.application_knative.services_for(ns: cluster.platform_kubernetes&.actual_namespace) + services = cluster.application_knative.services_for(ns: cluster.kubernetes_namespace_for(project)) .select { |svc| svc["metadata"]["name"] == name } add_metadata(cluster, services).first unless services.nil? @@ -52,7 +54,7 @@ module Projects def knative_services clusters_with_knative_installed.preload_knative.map do |cluster| - services = cluster.application_knative.services_for(ns: cluster.platform_kubernetes&.actual_namespace) + services = cluster.application_knative.services_for(ns: cluster.kubernetes_namespace_for(project)) add_metadata(cluster, services) unless services.nil? end end @@ -64,7 +66,7 @@ module Projects if services.length == 1 s["podcount"] = cluster.application_knative.service_pod_details( - cluster.platform_kubernetes&.actual_namespace, + cluster.kubernetes_namespace_for(project), s["metadata"]["name"]).length end end @@ -76,7 +78,7 @@ module Projects # rubocop: disable CodeReuse/ServiceClass def prometheus_adapter - @prometheus_adapter ||= ::Prometheus::AdapterService.new(@project).prometheus_adapter + @prometheus_adapter ||= ::Prometheus::AdapterService.new(project).prometheus_adapter end # rubocop: enable CodeReuse/ServiceClass end |