diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-03 23:24:32 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-03 23:24:32 +0200 |
commit | e8e2a2103a806873f338da4b1de21a3df9c65502 (patch) | |
tree | 1317642dbca4fc86908ee38cf155d35ce61fa9e9 | |
parent | 25a1ef69333280201bf745192e178f5a8e3f9165 (diff) | |
download | gitlab-ce-e8e2a2103a806873f338da4b1de21a3df9c65502.tar.gz |
Rename to ClusterProvisionWorker and CreateGkeClusterService.new.execute
-rw-r--r-- | app/services/ci/create_cluster_service.rb | 2 | ||||
-rw-r--r-- | app/services/ci/provision_cluster_service.rb (renamed from app/services/ci/create_gke_cluster_service.rb) | 10 | ||||
-rw-r--r-- | app/workers/cluster_provision_worker.rb (renamed from app/workers/cluster_creation_worker.rb) | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/app/services/ci/create_cluster_service.rb b/app/services/ci/create_cluster_service.rb index 2fb6df9d669..179dfa0c6bb 100644 --- a/app/services/ci/create_cluster_service.rb +++ b/app/services/ci/create_cluster_service.rb @@ -7,7 +7,7 @@ module Ci params.merge(user: current_user, status: Gcp::Cluster.statuses[:scheduled], gcp_token: access_token)).tap do |cluster| - ClusterCreationWorker.perform_async(cluster.id) if cluster.persisted? + ClusterProvisionWorker.perform_async(cluster.id) if cluster.persisted? end end end diff --git a/app/services/ci/create_gke_cluster_service.rb b/app/services/ci/provision_cluster_service.rb index 2407de5fc75..3e7e565b361 100644 --- a/app/services/ci/create_gke_cluster_service.rb +++ b/app/services/ci/provision_cluster_service.rb @@ -1,5 +1,5 @@ module Ci - class CreateGkeClusterService + class ProvisionClusterService def execute(cluster) api_client = GoogleApi::CloudPlatform::Client.new(cluster.gcp_token, nil) @@ -15,18 +15,18 @@ module Ci rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e return cluster.errored!("Failed to request to CloudPlatform; #{e.message}") end - + unless operation.status == 'RUNNING' || operation.status == 'PENDING' return cluster.errored!("Operation status is unexpected; #{operation.status_message}") end - operation_id = api_client.parse_operation_id(operation.self_link) + cluster.gcp_operation_id = api_client.parse_operation_id(operation.self_link) - unless operation_id + unless cluster.gcp_operation_id return cluster.errored!('Can not find operation_id from self_link') end - if cluster.creating!(operation_id) + if cluster.creating WaitForClusterCreationWorker.perform_in( WaitForClusterCreationWorker::INITIAL_INTERVAL, cluster.id) else diff --git a/app/workers/cluster_creation_worker.rb b/app/workers/cluster_provision_worker.rb index d4ca9029a91..63300b58a25 100644 --- a/app/workers/cluster_creation_worker.rb +++ b/app/workers/cluster_provision_worker.rb @@ -1,10 +1,10 @@ -class ClusterCreationWorker +class ClusterProvisionWorker include Sidekiq::Worker include ClusterQueue def perform(cluster_id) Gcp::Cluster.find_by_id(cluster_id).try do |cluster| - Ci::CreateGkeClusterService.new.execute(cluster) + Ci::ProvisionClusterService.new.execute(cluster) end end end |