2019-04-09 22:50:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Clusters
|
|
|
|
module Applications
|
2019-08-29 13:21:35 -04:00
|
|
|
class CheckUninstallProgressService < CheckProgressService
|
|
|
|
private
|
2019-04-09 22:50:14 -04:00
|
|
|
|
2019-08-29 13:21:35 -04:00
|
|
|
def operation_in_progress?
|
|
|
|
app.uninstalling?
|
2019-04-09 22:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_success
|
2019-07-16 12:11:10 -04:00
|
|
|
app.post_uninstall
|
2019-04-12 01:28:06 -04:00
|
|
|
app.destroy!
|
|
|
|
rescue StandardError => e
|
2019-04-30 00:49:26 -04:00
|
|
|
app.make_errored!(_('Application uninstalled but failed to destroy: %{error_message}') % { error_message: e.message })
|
2019-04-09 22:50:14 -04:00
|
|
|
ensure
|
2019-09-04 19:26:57 -04:00
|
|
|
remove_uninstallation_pod
|
2019-04-09 22:50:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_timeout
|
2019-04-29 01:57:12 -04:00
|
|
|
if timed_out?
|
2019-04-30 00:49:26 -04:00
|
|
|
app.make_errored!(_('Operation timed out. Check pod logs for %{pod_name} for more details.') % { pod_name: pod_name })
|
2019-04-09 22:50:14 -04:00
|
|
|
else
|
|
|
|
WaitForUninstallAppWorker.perform_in(WaitForUninstallAppWorker::INTERVAL, app.name, app.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def pod_name
|
|
|
|
app.uninstall_command.pod_name
|
|
|
|
end
|
|
|
|
|
2019-04-29 01:57:12 -04:00
|
|
|
def timed_out?
|
2019-04-30 00:59:48 -04:00
|
|
|
Time.now.utc - app.updated_at.utc > WaitForUninstallAppWorker::TIMEOUT
|
2019-04-09 22:50:14 -04:00
|
|
|
end
|
2019-09-04 19:26:57 -04:00
|
|
|
|
|
|
|
def remove_uninstallation_pod
|
|
|
|
helm_api.delete_pod!(pod_name)
|
|
|
|
end
|
2019-04-09 22:50:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|