Welcome to mirror list, hosted at ThFree Co, Russian Federation.

check_uninstall_progress_service.rb « applications « clusters « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cd213c3ebbf8c250d1388ca5f85b327456bae6ef (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
# frozen_string_literal: true

module Clusters
  module Applications
    class CheckUninstallProgressService < CheckProgressService
      private

      def operation_in_progress?
        app.uninstalling?
      end

      def on_success
        app.post_uninstall
        app.destroy!
      rescue StandardError => e
        app.make_errored!(_('Application uninstalled but failed to destroy: %{error_message}') % { error_message: e.message })
      ensure
        remove_uninstallation_pod
      end

      def check_timeout
        if timed_out?
          app.make_errored!(_('Operation timed out. Check pod logs for %{pod_name} for more details.') % { pod_name: pod_name })
        else
          WaitForUninstallAppWorker.perform_in(WaitForUninstallAppWorker::INTERVAL, app.name, app.id)
        end
      end

      def pod_name
        app.uninstall_command.pod_name
      end

      def timed_out?
        Time.current.utc - app.updated_at.utc > WaitForUninstallAppWorker::TIMEOUT
      end

      def remove_uninstallation_pod
        helm_api.delete_pod!(pod_name)
      end
    end
  end
end