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 ...@@ -67,15 +67,15 @@ module Gcp
validate :restrict_modification, on: :update, unless: :status_changed? validate :restrict_modification, on: :update, unless: :status_changed?
state_machine :status, initial: :scheduled do state_machine :status, initial: :scheduled do
event :creating do event :make_creating do
transition any - [:creating] => :creating transition any - [:creating] => :creating
end end
event :created do event :make_created do
transition any - [:created] => :created transition any - [:created] => :created
end end
event :errored do event :make_errored do
transition any - [:errored] => :errored transition any - [:errored] => :errored
end end
......
...@@ -11,7 +11,7 @@ module Ci ...@@ -11,7 +11,7 @@ module Ci
yield(operation) if block_given? yield(operation) if block_given?
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e 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 end
end end
...@@ -10,7 +10,7 @@ module Ci ...@@ -10,7 +10,7 @@ module Ci
cluster.gcp_cluster_zone, cluster.gcp_cluster_zone,
cluster.gcp_cluster_name) cluster.gcp_cluster_name)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e 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
endpoint = gke_cluster.endpoint endpoint = gke_cluster.endpoint
...@@ -23,7 +23,7 @@ module Ci ...@@ -23,7 +23,7 @@ module Ci
api_url, ca_cert, username, password).execute api_url, ca_cert, username, password).execute
unless kubernetes_token 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 end
Ci::IntegrateClusterService.new.execute( Ci::IntegrateClusterService.new.execute(
......
...@@ -10,7 +10,7 @@ module Ci ...@@ -10,7 +10,7 @@ module Ci
username: username, username: username,
password: password, password: password,
service: cluster.project.find_or_initialize_service('kubernetes'), service: cluster.project.find_or_initialize_service('kubernetes'),
status_event: :created) status_event: :make_created)
cluster.service.update!( cluster.service.update!(
active: true, active: true,
......
...@@ -12,24 +12,24 @@ module Ci ...@@ -12,24 +12,24 @@ module Ci
cluster.gcp_cluster_size, cluster.gcp_cluster_size,
machine_type: cluster.gcp_machine_type) machine_type: cluster.gcp_machine_type)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e 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
unless operation.status == 'RUNNING' || operation.status == 'PENDING' 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 end
cluster.gcp_operation_id = api_client.parse_operation_id(operation.self_link) cluster.gcp_operation_id = api_client.parse_operation_id(operation.self_link)
unless cluster.gcp_operation_id 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 end
if cluster.creating if cluster.make_creating
WaitForClusterCreationWorker.perform_in( WaitForClusterCreationWorker.perform_in(
WaitForClusterCreationWorker::INITIAL_INTERVAL, cluster.id) WaitForClusterCreationWorker::INITIAL_INTERVAL, cluster.id)
else 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 end
end end
......
...@@ -12,14 +12,14 @@ class WaitForClusterCreationWorker ...@@ -12,14 +12,14 @@ class WaitForClusterCreationWorker
case operation.status case operation.status
when 'RUNNING' when 'RUNNING'
if TIMEOUT < Time.zone.now - operation.start_time.to_time 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 end
WaitForClusterCreationWorker.perform_in(EAGER_INTERVAL, cluster.id) WaitForClusterCreationWorker.perform_in(EAGER_INTERVAL, cluster.id)
when 'DONE' when 'DONE'
Ci::FinalizeClusterCreationService.new.execute(cluster) Ci::FinalizeClusterCreationService.new.execute(cluster)
else 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 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