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:
parent
2cdb72ea03
commit
4615dca1d9
2 changed files with 5 additions and 21 deletions
|
@ -20,9 +20,7 @@ module Gitlab
|
||||||
private
|
private
|
||||||
|
|
||||||
def deployment_cluster
|
def deployment_cluster
|
||||||
strong_memoize(:deployment_cluster) do
|
build.deployment&.cluster
|
||||||
build.deployment&.cluster || build.deployment&.deployment_platform_cluster
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def kubernetes_namespace
|
def kubernetes_namespace
|
||||||
|
|
|
@ -17,15 +17,12 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'build has a deployment' do
|
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
|
context 'and a cluster to deploy to' do
|
||||||
let(:cluster) { create(:cluster, :group) }
|
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 }
|
it { is_expected.to be_truthy }
|
||||||
|
|
||||||
context 'and the cluster is not managed' do
|
context 'and the cluster is not managed' do
|
||||||
|
@ -48,28 +45,21 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and no cluster to deploy to' do
|
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 }
|
it { is_expected.to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#complete!' do
|
describe '#complete!' do
|
||||||
let!(:deployment) { create(:deployment, deployable: build) }
|
let!(:deployment) { create(:deployment, deployable: build, cluster: cluster) }
|
||||||
let(:service) { double(execute: true) }
|
let(:service) { double(execute: true) }
|
||||||
|
let(:cluster) { nil }
|
||||||
|
|
||||||
subject { described_class.new(build).complete! }
|
subject { described_class.new(build).complete! }
|
||||||
|
|
||||||
context 'completion is required' do
|
context 'completion is required' do
|
||||||
let(:cluster) { create(:cluster, :group) }
|
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
|
it 'creates a kubernetes namespace' do
|
||||||
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService)
|
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService)
|
||||||
.to receive(:new)
|
.to receive(:new)
|
||||||
|
@ -83,10 +73,6 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'completion is not required' do
|
context 'completion is not required' do
|
||||||
before do
|
|
||||||
expect(deployment.deployment_platform_cluster).to be_nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create a namespace' do
|
it 'does not create a namespace' do
|
||||||
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:new)
|
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:new)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue