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
c46417c5
Commit
c46417c5
authored
Nov 02, 2017
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename App to Applications
parent
880cf60b
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
126 additions
and
122 deletions
+126
-122
app/models/clusters/concerns.rb
app/models/clusters/concerns.rb
+0
-4
app/services/clusters/applications/base_helm_service.rb
app/services/clusters/applications/base_helm_service.rb
+25
-0
app/services/clusters/applications/check_installation_progress_service.rb
...sters/applications/check_installation_progress_service.rb
+30
-0
app/services/clusters/applications/fetch_installation_status_service.rb
...lusters/applications/fetch_installation_status_service.rb
+15
-0
app/services/clusters/applications/finalize_installation_service.rb
...es/clusters/applications/finalize_installation_service.rb
+17
-0
app/services/clusters/applications/install_service.rb
app/services/clusters/applications/install_service.rb
+24
-0
app/services/clusters/base_helm_service.rb
app/services/clusters/base_helm_service.rb
+0
-23
app/services/clusters/check_app_installation_progress_service.rb
...vices/clusters/check_app_installation_progress_service.rb
+0
-28
app/services/clusters/fetch_app_installation_status_service.rb
...ervices/clusters/fetch_app_installation_status_service.rb
+0
-13
app/services/clusters/finalize_app_installation_service.rb
app/services/clusters/finalize_app_installation_service.rb
+0
-15
app/services/clusters/install_app_service.rb
app/services/clusters/install_app_service.rb
+0
-22
app/workers/cluster_install_app_worker.rb
app/workers/cluster_install_app_worker.rb
+3
-3
app/workers/cluster_wait_for_app_installation_worker.rb
app/workers/cluster_wait_for_app_installation_worker.rb
+3
-3
app/workers/concerns/cluster_app.rb
app/workers/concerns/cluster_app.rb
+0
-11
app/workers/concerns/cluster_applications.rb
app/workers/concerns/cluster_applications.rb
+9
-0
No files found.
app/models/clusters/concerns.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
module
Concerns
end
end
app/services/clusters/applications/base_helm_service.rb
0 → 100644
View file @
c46417c5
module
Clusters
module
Applications
class
BaseHelmService
attr_accessor
:app
def
initialize
(
app
)
@app
=
app
end
protected
def
cluster
app
.
cluster
end
def
kubeclient
cluster
.
kubeclient
end
def
helm_api
@helm_api
||=
Gitlab
::
Kubernetes
::
Helm
.
new
(
kubeclient
)
end
end
end
end
app/services/clusters/applications/check_installation_progress_service.rb
0 → 100644
View file @
c46417c5
module
Clusters
module
Applications
class
CheckInstallationProgressService
<
BaseHelmService
def
execute
return
unless
app
.
installing?
FetchInstallationStatusService
.
new
(
app
).
execute
do
|
phase
,
log
|
case
phase
when
'Succeeded'
if
app
.
make_installed
FinalizeInstallationService
.
new
(
app
).
execute
else
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
end
when
'Failed'
app
.
make_errored!
(
log
||
'Installation silently failed'
)
FinalizeInstallationService
.
new
(
app
).
execute
else
if
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
app
.
make_errored!
(
'App installation timeouted'
)
else
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
EAGER_INTERVAL
,
app
.
name
,
app
.
id
)
end
end
end
end
end
end
end
app/services/clusters/applications/fetch_installation_status_service.rb
0 → 100644
View file @
c46417c5
module
Clusters
module
Applications
class
FetchInstallationStatusService
<
BaseHelmService
def
execute
return
unless
app
.
installing?
phase
=
helm_api
.
installation_status
(
app
)
log
=
helm_api
.
installation_log
(
app
)
if
phase
==
'Failed'
yield
(
phase
,
log
)
if
block_given?
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
unless
app
.
errored?
end
end
end
end
app/services/clusters/applications/finalize_installation_service.rb
0 → 100644
View file @
c46417c5
module
Clusters
module
Applications
class
FinalizeInstallationService
<
BaseHelmService
def
execute
helm_api
.
delete_installation_pod!
(
app
)
app
.
make_errored!
(
'Installation aborted'
)
if
aborted?
end
private
def
aborted?
app
.
installing?
||
app
.
scheduled?
end
end
end
end
app/services/clusters/applications/install_service.rb
0 → 100644
View file @
c46417c5
module
Clusters
module
Applications
class
InstallService
<
BaseHelmService
def
execute
return
unless
app
.
scheduled?
begin
helm_api
.
install
(
app
)
if
app
.
make_installing
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INITIAL_INTERVAL
,
app
.
name
,
app
.
id
)
else
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
end
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
rescue
StandardError
app
.
make_errored!
(
"Can't start installation process"
)
end
end
end
end
end
app/services/clusters/base_helm_service.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
class
BaseHelmService
attr_accessor
:app
def
initialize
(
app
)
@app
=
app
end
protected
def
cluster
app
.
cluster
end
def
kubeclient
cluster
.
kubeclient
end
def
helm_api
@helm_api
||=
Gitlab
::
Kubernetes
::
Helm
.
new
(
kubeclient
)
end
end
end
app/services/clusters/check_app_installation_progress_service.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
class
CheckAppInstallationProgressService
<
BaseHelmService
def
execute
return
unless
app
.
installing?
FetchAppInstallationStatusService
.
new
(
app
).
execute
do
|
phase
,
log
|
case
phase
when
'Succeeded'
if
app
.
make_installed
FinalizeAppInstallationService
.
new
(
app
).
execute
else
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
end
when
'Failed'
app
.
make_errored!
(
log
||
'Installation silently failed'
)
FinalizeAppInstallationService
.
new
(
app
).
execute
else
if
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
app
.
make_errored!
(
'App installation timeouted'
)
else
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
EAGER_INTERVAL
,
app
.
name
,
app
.
id
)
end
end
end
end
end
end
app/services/clusters/fetch_app_installation_status_service.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
class
FetchAppInstallationStatusService
<
BaseHelmService
def
execute
return
unless
app
.
installing?
phase
=
helm_api
.
installation_status
(
app
)
log
=
helm_api
.
installation_log
(
app
)
if
phase
==
'Failed'
yield
(
phase
,
log
)
if
block_given?
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
unless
app
.
errored?
end
end
end
app/services/clusters/finalize_app_installation_service.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
class
FinalizeAppInstallationService
<
BaseHelmService
def
execute
helm_api
.
delete_installation_pod!
(
app
)
app
.
make_errored!
(
'Installation aborted'
)
if
aborted?
end
private
def
aborted?
app
.
installing?
||
app
.
scheduled?
end
end
end
app/services/clusters/install_app_service.rb
deleted
100644 → 0
View file @
880cf60b
module
Clusters
class
InstallAppService
<
BaseHelmService
def
execute
return
unless
app
.
scheduled?
begin
helm_api
.
install
(
app
)
if
app
.
make_installing
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INITIAL_INTERVAL
,
app
.
name
,
app
.
id
)
else
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
end
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
rescue
StandardError
app
.
make_errored!
(
"Can't start installation process"
)
end
end
end
end
app/workers/cluster_install_app_worker.rb
View file @
c46417c5
class
ClusterInstallAppWorker
class
ClusterInstallAppWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
ClusterQueue
include
ClusterQueue
include
ClusterApp
include
ClusterApp
lications
def
perform
(
app_name
,
app_id
)
def
perform
(
app_name
,
app_id
)
find_app
(
app_name
,
app_id
)
do
|
app
|
find_app
lication
(
app_name
,
app_id
)
do
|
app
|
Clusters
::
InstallApp
Service
.
new
(
app
).
execute
Clusters
::
Applications
::
Install
Service
.
new
(
app
).
execute
end
end
end
end
end
end
app/workers/cluster_wait_for_app_installation_worker.rb
View file @
c46417c5
class
ClusterWaitForAppInstallationWorker
class
ClusterWaitForAppInstallationWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
ClusterQueue
include
ClusterQueue
include
ClusterApp
include
ClusterApp
lications
INITIAL_INTERVAL
=
30
.
seconds
INITIAL_INTERVAL
=
30
.
seconds
EAGER_INTERVAL
=
10
.
seconds
EAGER_INTERVAL
=
10
.
seconds
TIMEOUT
=
20
.
minutes
TIMEOUT
=
20
.
minutes
def
perform
(
app_name
,
app_id
)
def
perform
(
app_name
,
app_id
)
find_app
(
app_name
,
app_id
)
do
|
app
|
find_app
lication
(
app_name
,
app_id
)
do
|
app
|
Clusters
::
CheckApp
InstallationProgressService
.
new
(
app
).
execute
Clusters
::
Applications
::
Check
InstallationProgressService
.
new
(
app
).
execute
end
end
end
end
end
end
app/workers/concerns/cluster_app.rb
deleted
100644 → 0
View file @
880cf60b
module
ClusterApp
extend
ActiveSupport
::
Concern
included
do
def
find_app
(
app_name
,
id
)
Clusters
::
Cluster
::
APPLICATIONS
[
app_name
].
find
(
id
).
try
do
|
app
|
yield
(
app
)
if
block_given?
end
end
end
end
app/workers/concerns/cluster_applications.rb
0 → 100644
View file @
c46417c5
module
ClusterApplications
extend
ActiveSupport
::
Concern
included
do
def
find_application
(
app_name
,
id
,
&
blk
)
Clusters
::
Cluster
::
APPLICATIONS
[
app_name
].
find
(
id
).
try
(
&
blk
)
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