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.
This commit is contained in:
Thong Kuah 2019-06-25 17:06:37 +12:00
parent 2cdb72ea03
commit 4615dca1d9
2 changed files with 5 additions and 21 deletions

View File

@ -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

View File

@ -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)