Commit e8e2a210 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename to ClusterProvisionWorker and CreateGkeClusterService.new.execute

parent 25a1ef69
......@@ -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
......
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
......
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
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