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 /spec/models/project_services | |
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 'spec/models/project_services')
-rw-r--r-- | spec/models/project_services/kubernetes_service_spec.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 3a381cb405d..2fce120381b 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -161,8 +161,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do end end - describe '#actual_namespace' do - subject { service.actual_namespace } + describe '#kubernetes_namespace_for' do + subject { service.kubernetes_namespace_for(project) } shared_examples 'a correctly formatted namespace' do it 'returns a valid Kubernetes namespace name' do @@ -298,7 +298,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do end context 'no namespace provided' do - let(:namespace) { subject.actual_namespace } + let(:namespace) { subject.kubernetes_namespace_for(project) } it_behaves_like 'setting variables' @@ -325,7 +325,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do end context 'with valid pods' do - let(:pod) { kube_pod(environment_slug: environment.slug, project_slug: project.full_path_slug) } + let(:pod) { kube_pod(environment_slug: environment.slug, namespace: service.kubernetes_namespace_for(project), project_slug: project.full_path_slug) } let(:pod_with_no_terminal) { kube_pod(environment_slug: environment.slug, project_slug: project.full_path_slug, status: "Pending") } let(:terminals) { kube_terminals(service, pod) } @@ -352,6 +352,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do describe '#calculate_reactive_cache' do subject { service.calculate_reactive_cache } + let(:namespace) { service.kubernetes_namespace_for(project) } + context 'when service is inactive' do before do service.active = false @@ -362,8 +364,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do context 'when kubernetes responds with valid pods' do before do - stub_kubeclient_pods - stub_kubeclient_deployments # Used by EE + stub_kubeclient_pods(namespace) + stub_kubeclient_deployments(namespace) # Used by EE end it { is_expected.to include(pods: [kube_pod]) } @@ -371,8 +373,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do context 'when kubernetes responds with 500s' do before do - stub_kubeclient_pods(status: 500) - stub_kubeclient_deployments(status: 500) # Used by EE + stub_kubeclient_pods(namespace, status: 500) + stub_kubeclient_deployments(namespace, status: 500) # Used by EE end it { expect { subject }.to raise_error(Kubeclient::HttpError) } @@ -380,8 +382,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do context 'when kubernetes responds with 404s' do before do - stub_kubeclient_pods(status: 404) - stub_kubeclient_deployments(status: 404) # Used by EE + stub_kubeclient_pods(namespace, status: 404) + stub_kubeclient_deployments(namespace, status: 404) # Used by EE end it { is_expected.to include(pods: []) } |