blob: 7f5a633b7491dcae0b36f763cd23ccaf2a6976a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
module Clusters
module Applications
class CheckInstallationProgressService < BaseHelmService
def execute
return unless app.installing?
case installation_phase
when Gitlab::Kubernetes::Pod::SUCCEEDED
on_succeeded
when Gitlab::Kubernetes::Pod::FAILED
on_failed
else
check_timeout
end
rescue KubeException => ke
app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored?
end
private
def on_succeeded
if app.make_installed
finalize_installation
else
app.make_errored!("Failed to update app record; #{app.errors}")
end
end
def on_failed
app.make_errored!(log || 'Installation silently failed')
finalize_installation
end
def check_timeout
if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
app.make_errored!('App installation timeouted')
else
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
end
end
def finilize_installation
FinalizeInstallationService.new(app).execute
end
def installation_phase
helm_api.installation_status(app)
end
def installation_errors
helm_api.installation_log(app)
end
end
end
end
|