summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-01 20:30:32 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-01 20:30:32 +0900
commit5663b4808df787b1bcbf32ba54eccbb4c7537e25 (patch)
treedb851b0b94ee77d493dc787f67fe63136dab4fef /app/workers
parent2d1a77b8a3567cae61f73196918fe365d4fe9415 (diff)
downloadgitlab-ce-5663b4808df787b1bcbf32ba54eccbb4c7537e25.tar.gz
authorize in controller. validation in model.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/cluster_creation_worker.rb11
-rw-r--r--app/workers/wait_for_cluster_creation_worker.rb12
2 files changed, 11 insertions, 12 deletions
diff --git a/app/workers/cluster_creation_worker.rb b/app/workers/cluster_creation_worker.rb
index 0b547089b94..40e40005022 100644
--- a/app/workers/cluster_creation_worker.rb
+++ b/app/workers/cluster_creation_worker.rb
@@ -21,27 +21,26 @@ class ClusterCreationWorker
)
if operation.is_a?(StandardError)
- return cluster.error!("Failed to request to CloudPlatform; #{operation.message}")
+ return cluster.errored!("Failed to request to CloudPlatform; #{operation.message}")
end
unless operation.status == 'RUNNING' || operation.status == 'PENDING'
- return cluster.error!("Operation status is unexpected; #{operation.status_message}")
+ return cluster.errored!("Operation status is unexpected; #{operation.status_message}")
end
operation_id = api_client.parse_operation_id(operation.self_link)
unless operation_id
- return cluster.error!('Can not find operation_id from self_link')
+ return cluster.errored!('Can not find operation_id from self_link')
end
- if cluster.update(status: Ci::Cluster.statuses[:creating],
- gcp_operation_id: operation_id)
+ if cluster.creating!(operation_id)
WaitForClusterCreationWorker.perform_in(
WaitForClusterCreationWorker::INITIAL_INTERVAL,
cluster.id
)
else
- return cluster.error!("Failed to update cluster record; #{cluster.errors}")
+ return cluster.errored!("Failed to update cluster record; #{cluster.errors}")
end
end
end
diff --git a/app/workers/wait_for_cluster_creation_worker.rb b/app/workers/wait_for_cluster_creation_worker.rb
index 8d84f28c0cf..5ffe70d4ba6 100644
--- a/app/workers/wait_for_cluster_creation_worker.rb
+++ b/app/workers/wait_for_cluster_creation_worker.rb
@@ -22,7 +22,7 @@ class WaitForClusterCreationWorker
cluster.gcp_operation_id)
if operation.is_a?(StandardError)
- return cluster.error!("Failed to request to CloudPlatform; #{operation.message}")
+ return cluster.errored!("Failed to request to CloudPlatform; #{operation.message}")
end
case operation.status
@@ -30,12 +30,12 @@ class WaitForClusterCreationWorker
if Time.now < operation.start_time.to_time + TIMEOUT
WaitForClusterCreationWorker.perform_in(EAGER_INTERVAL, cluster.id)
else
- return cluster.error!("Cluster creation time exceeds timeout; #{TIMEOUT}")
+ return cluster.errored!("Cluster creation time exceeds timeout; #{TIMEOUT}")
end
when 'DONE'
integrate(cluster, api_client)
else
- return cluster.error!("Unexpected operation status; #{operation.status} #{operation.status_message}")
+ return cluster.errored!("Unexpected operation status; #{operation.status} #{operation.status_message}")
end
end
@@ -46,7 +46,7 @@ class WaitForClusterCreationWorker
cluster.cluster_name)
if gke_cluster.is_a?(StandardError)
- return cluster.error!("Failed to request to CloudPlatform; #{gke_cluster.message}")
+ return cluster.errored!("Failed to request to CloudPlatform; #{gke_cluster.message}")
end
begin
@@ -56,14 +56,14 @@ class WaitForClusterCreationWorker
username = gke_cluster.master_auth.username
password = gke_cluster.master_auth.password
rescue Exception => e
- return cluster.error!("Can not extract the extected data; #{e}")
+ return cluster.errored!("Can not extract the extected data; #{e}")
end
kubernetes_token = Ci::FetchKubernetesTokenService.new(
api_url, ca_cert, username, password).execute
unless kubernetes_token
- return cluster.error!('Failed to get a default token of kubernetes')
+ return cluster.errored!('Failed to get a default token of kubernetes')
end
Ci::IntegrateClusterService.new.execute(