Class: Actions::Middleware::BackendServicesCheck

Inherits:
Dynflow::Middleware
  • Object
show all
Defined in:
app/lib/actions/middleware/backend_services_check.rb

Instance Method Summary collapse

Instance Method Details

#plan(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/lib/actions/middleware/backend_services_check.rb', line 4

def plan(*args)
  if Setting[:check_services_before_actions]
    #To prevent the ping from happening multiple times, keep track on the initial entry action
    #If capsule_id is passed as in args from an action, Katello::Ping checks the pulp server on the capsule
    parent = source_action
    parent.input[:services_checked] ||= []
    to_check = services - parent.input[:services_checked]

    if to_check.any?
      result = User.as_anonymous_admin { ::Katello::Ping.ping(services: to_check, capsule_id: capsule_id(args))[:services] }

      to_check.each do |service|
        if result[service][:status] != ::Katello::Ping::OK_RETURN_CODE
          fail _("There was an issue with the backend service %s: ") % service + result[service][:message]
        end
      end
      parent.input[:services_checked].concat(to_check)
    end
  end
  pass(*args)
end