summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-06-25 17:06:37 +1200
committerThong Kuah <tkuah@gitlab.com>2019-06-27 17:28:52 +1200
commit4615dca1d90975d16b1534292c1b2886da1b2cd5 (patch)
tree01865b93ac2b6c4f4bf5ea19f33ae9bf65980c87
parent2cdb72ea0382ef80f6cd24606826094321a4e643 (diff)
downloadgitlab-ce-4615dca1d90975d16b1534292c1b2886da1b2cd5.tar.gz
Drop fallback to deployment platform
All deployments should have already their cluster_id filled in on creation. Legacy deployments will not be retried as:- * Ci::Build#retry calls `Ci::RetryBuildService` * Ci::Pipeline#retry calls `Ci::RetryPipelineService` which also calls `Ci::RetryBuildService` * `Ci::RetryBuildService` will clone a build to retry It is also impossibly to backfill Deployment#cluster_id from Project#deployment_platform correctly as clusters could have been deleted, added or altered in the intervening time.
-rw-r--r--lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb4
-rw-r--r--spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb22
2 files changed, 5 insertions, 21 deletions
diff --git a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
index 48598fcae7e..e6e0aaab60b 100644
--- a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
+++ b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
@@ -20,9 +20,7 @@ module Gitlab
private
def deployment_cluster
- strong_memoize(:deployment_cluster) do
- build.deployment&.cluster || build.deployment&.deployment_platform_cluster
- end
+ build.deployment&.cluster
end
def kubernetes_namespace
diff --git a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
index 51e16c99688..d88a2097ba2 100644
--- a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
+++ b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
@@ -17,15 +17,12 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end
context 'build has a deployment' do
- let!(:deployment) { create(:deployment, deployable: build) }
+ let!(:deployment) { create(:deployment, deployable: build, cluster: cluster) }
+ let(:cluster) { nil }
context 'and a cluster to deploy to' do
let(:cluster) { create(:cluster, :group) }
- before do
- allow(build.deployment).to receive(:deployment_platform_cluster).and_return(cluster)
- end
-
it { is_expected.to be_truthy }
context 'and the cluster is not managed' do
@@ -48,28 +45,21 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end
context 'and no cluster to deploy to' do
- before do
- expect(deployment.deployment_platform_cluster).to be_nil
- end
-
it { is_expected.to be_falsey }
end
end
end
describe '#complete!' do
- let!(:deployment) { create(:deployment, deployable: build) }
+ let!(:deployment) { create(:deployment, deployable: build, cluster: cluster) }
let(:service) { double(execute: true) }
+ let(:cluster) { nil }
subject { described_class.new(build).complete! }
context 'completion is required' do
let(:cluster) { create(:cluster, :group) }
- before do
- allow(build.deployment).to receive(:deployment_platform_cluster).and_return(cluster)
- end
-
it 'creates a kubernetes namespace' do
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService)
.to receive(:new)
@@ -83,10 +73,6 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
end
context 'completion is not required' do
- before do
- expect(deployment.deployment_platform_cluster).to be_nil
- end
-
it 'does not create a namespace' do
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:new)