Commit 28b0b9c1 authored by Thong Kuah's avatar Thong Kuah

Call ClusterPlatformConfigureWorker to re-use code

We remove configure_project_service_account and replace
ClusterPlatformConfigureWorker as they perform exactly the same piece of
work. This also makes GKE cluster creation to be the same as Adding
existing cluster - they both now use another worker to execute
CreateOrUpdateNamespaceService.
parent 76d4e6d6
...@@ -12,7 +12,8 @@ module Clusters ...@@ -12,7 +12,8 @@ module Clusters
create_gitlab_service_account! create_gitlab_service_account!
configure_kubernetes configure_kubernetes
cluster.save! cluster.save!
configure_project_service_account
ClusterPlatformConfigureWorker.perform_async(cluster.id)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
provider.make_errored!("Failed to request to CloudPlatform; #{e.message}") provider.make_errored!("Failed to request to CloudPlatform; #{e.message}")
...@@ -55,15 +56,6 @@ module Clusters ...@@ -55,15 +56,6 @@ module Clusters
).execute ).execute
end end
def configure_project_service_account
kubernetes_namespace = cluster.find_or_initialize_kubernetes_namespace(cluster.cluster_project)
Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService.new(
cluster: cluster,
kubernetes_namespace: kubernetes_namespace
).execute
end
def authorization_type def authorization_type
create_rbac_cluster? ? 'rbac' : 'abac' create_rbac_cluster? ? 'rbac' : 'abac'
end end
......
...@@ -48,6 +48,12 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do ...@@ -48,6 +48,12 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
expect(kubernetes_namespace.service_account_name).to eq("#{namespace}-service-account") expect(kubernetes_namespace.service_account_name).to eq("#{namespace}-service-account")
expect(kubernetes_namespace.service_account_token).to be_present expect(kubernetes_namespace.service_account_token).to be_present
end end
it 'calls ClusterPlatformConfigureWorker in a ascync fashion' do
expect(ClusterPlatformConfigureWorker).to receive(:perform_async).with(cluster.id)
subject
end
end end
shared_examples 'error' do shared_examples 'error' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment