Class: Shipitron::Client::EnsureDeployNotRunning

Inherits:
Object
  • Object
show all
Includes:
Metaractor, EcsClient
Defined in:
lib/shipitron/client/ensure_deploy_not_running.rb

Instance Method Summary collapse

Methods included from EcsClient

#ecs_client, #generate_ecs_client

Instance Method Details

#callObject



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
# File 'lib/shipitron/client/ensure_deploy_not_running.rb', line 17

def call
  return if simulate?

  clusters.each do |cluster|
    %w[PENDING RUNNING].each do |status|
      begin
        response = ecs_client(region: cluster.region).list_tasks(
          cluster: cluster.name,
          started_by: Shipitron::Client::STARTED_BY,
          max_results: 1,
          desired_status: status
        )
        if !response.task_arns.empty?
          fail_with_errors!(messages: [
            'Shipitron says "THERE CAN BE ONLY ONE"',
            'Deploy is already running.'
          ])
        end
      rescue Aws::ECS::Errors::ClusterNotFoundException
        fail_with_errors!(messages: [
          'Shipitron says "PUNY HUMAN IS MISSING A CLUSTER"',
          "Cluster '#{cluster.name}' not found in region #{cluster.region}."
        ])
      end
    end
  end
end