Commit ea4af856 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix cluster event names to be prefixed with: `make_`

parent 7329a034
......@@ -67,15 +67,15 @@ module Gcp
validate :restrict_modification, on: :update, unless: :status_changed?
state_machine :status, initial: :scheduled do
event :creating do
event :make_creating do
transition any - [:creating] => :creating
end
event :created do
event :make_created do
transition any - [:created] => :created
end
event :errored do
event :make_errored do
transition any - [:errored] => :errored
end
......
......@@ -11,7 +11,7 @@ module Ci
yield(operation) if block_given?
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
return cluster.errored!("Failed to request to CloudPlatform; #{e.message}")
return cluster.make_errored!("Failed to request to CloudPlatform; #{e.message}")
end
end
end
......@@ -10,7 +10,7 @@ module Ci
cluster.gcp_cluster_zone,
cluster.gcp_cluster_name)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
return cluster.errored!("Failed to request to CloudPlatform; #{e.message}")
return cluster.make_errored!("Failed to request to CloudPlatform; #{e.message}")
end
endpoint = gke_cluster.endpoint
......@@ -23,7 +23,7 @@ module Ci
api_url, ca_cert, username, password).execute
unless kubernetes_token
return cluster.errored!('Failed to get a default token of kubernetes')
return cluster.make_errored!('Failed to get a default token of kubernetes')
end
Ci::IntegrateClusterService.new.execute(
......
......@@ -10,7 +10,7 @@ module Ci
username: username,
password: password,
service: cluster.project.find_or_initialize_service('kubernetes'),
status_event: :created)
status_event: :make_created)
cluster.service.update!(
active: true,
......
......@@ -12,24 +12,24 @@ module Ci
cluster.gcp_cluster_size,
machine_type: cluster.gcp_machine_type)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
return cluster.errored!("Failed to request to CloudPlatform; #{e.message}")
return cluster.make_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}")
return cluster.make_errored!("Operation status is unexpected; #{operation.status_message}")
end
cluster.gcp_operation_id = api_client.parse_operation_id(operation.self_link)
unless cluster.gcp_operation_id
return cluster.errored!('Can not find operation_id from self_link')
return cluster.make_errored!('Can not find operation_id from self_link')
end
if cluster.creating
if cluster.make_creating
WaitForClusterCreationWorker.perform_in(
WaitForClusterCreationWorker::INITIAL_INTERVAL, cluster.id)
else
return cluster.errored!("Failed to update cluster record; #{cluster.errors}")
return cluster.make_errored!("Failed to update cluster record; #{cluster.errors}")
end
end
end
......
......@@ -12,14 +12,14 @@ class WaitForClusterCreationWorker
case operation.status
when 'RUNNING'
if TIMEOUT < Time.zone.now - operation.start_time.to_time
return cluster.errored!("Cluster creation time exceeds timeout; #{TIMEOUT}")
return cluster.make_errored!("Cluster creation time exceeds timeout; #{TIMEOUT}")
end
WaitForClusterCreationWorker.perform_in(EAGER_INTERVAL, cluster.id)
when 'DONE'
Ci::FinalizeClusterCreationService.new.execute(cluster)
else
return cluster.errored!("Unexpected operation status; #{operation.status} #{operation.status_message}")
return cluster.make_errored!("Unexpected operation status; #{operation.status} #{operation.status_message}")
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