Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e8e2a210
Commit
e8e2a210
authored
Oct 03, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename to ClusterProvisionWorker and CreateGkeClusterService.new.execute
parent
25a1ef69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
app/services/ci/create_cluster_service.rb
app/services/ci/create_cluster_service.rb
+1
-1
app/services/ci/provision_cluster_service.rb
app/services/ci/provision_cluster_service.rb
+5
-5
app/workers/cluster_provision_worker.rb
app/workers/cluster_provision_worker.rb
+2
-2
No files found.
app/services/ci/create_cluster_service.rb
View file @
e8e2a210
...
@@ -7,7 +7,7 @@ module Ci
...
@@ -7,7 +7,7 @@ module Ci
params
.
merge
(
user:
current_user
,
params
.
merge
(
user:
current_user
,
status:
Gcp
::
Cluster
.
statuses
[
:scheduled
],
status:
Gcp
::
Cluster
.
statuses
[
:scheduled
],
gcp_token:
access_token
)).
tap
do
|
cluster
|
gcp_token:
access_token
)).
tap
do
|
cluster
|
Cluster
Creat
ionWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
persisted?
Cluster
Provis
ionWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
persisted?
end
end
end
end
end
end
...
...
app/services/ci/
create_gke
_cluster_service.rb
→
app/services/ci/
provision
_cluster_service.rb
View file @
e8e2a210
module
Ci
module
Ci
class
CreateGke
ClusterService
class
Provision
ClusterService
def
execute
(
cluster
)
def
execute
(
cluster
)
api_client
=
api_client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
cluster
.
gcp_token
,
nil
)
GoogleApi
::
CloudPlatform
::
Client
.
new
(
cluster
.
gcp_token
,
nil
)
...
@@ -15,18 +15,18 @@ module Ci
...
@@ -15,18 +15,18 @@ module Ci
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
.
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
.
errored!
(
"Operation status is unexpected;
#{
operation
.
status_message
}
"
)
end
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'
)
return
cluster
.
errored!
(
'Can not find operation_id from self_link'
)
end
end
if
cluster
.
creating
!
(
operation_id
)
if
cluster
.
creating
WaitForClusterCreationWorker
.
perform_in
(
WaitForClusterCreationWorker
.
perform_in
(
WaitForClusterCreationWorker
::
INITIAL_INTERVAL
,
cluster
.
id
)
WaitForClusterCreationWorker
::
INITIAL_INTERVAL
,
cluster
.
id
)
else
else
...
...
app/workers/cluster_
creat
ion_worker.rb
→
app/workers/cluster_
provis
ion_worker.rb
View file @
e8e2a210
class
Cluster
Creat
ionWorker
class
Cluster
Provis
ionWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
ClusterQueue
include
ClusterQueue
def
perform
(
cluster_id
)
def
perform
(
cluster_id
)
Gcp
::
Cluster
.
find_by_id
(
cluster_id
).
try
do
|
cluster
|
Gcp
::
Cluster
.
find_by_id
(
cluster_id
).
try
do
|
cluster
|
Ci
::
CreateGke
ClusterService
.
new
.
execute
(
cluster
)
Ci
::
Provision
ClusterService
.
new
.
execute
(
cluster
)
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment