Class: Rollo::Commands::Main

Inherits:
Thor
  • Object
show all
Defined in:
lib/rollo/commands/main.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rollo/commands/main.rb', line 13

def self.exit_on_failure?
  true
end

Instance Method Details

#roll(region, asg_name, ecs_cluster_name) ⇒ Object

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/rollo/commands/main.rb', line 53

def roll(region, asg_name, ecs_cluster_name)
  host_cluster = Rollo::Model::HostCluster.new(asg_name, region)
  service_cluster = Rollo::Model::ServiceCluster
                    .new(ecs_cluster_name, region)

  initial_hosts = host_cluster.hosts

  say(
    "Rolling instances in host cluster #{host_cluster.name} for " \
    "service cluster #{service_cluster.name}..."
  )
  # rubocop:disable Metrics/BlockLength
  with_padding do
    unless host_cluster.desired_capacity?
      say('ERROR: Host cluster is not in stable state.')
      say('This may be due to scaling above or below the desired')
      say('capacity or because hosts are not in service or are ')
      say('unhealthy. Cowardly refusing to roll instances.')
      exit 1
    end

    invoke(
      'hosts:expand',
      [
        region, asg_name, ecs_cluster_name,
        host_cluster
      ]
    )

    invoke(
      'services:expand',
      [
        region, asg_name, ecs_cluster_name,
        service_cluster
      ],
      maximum_instances: options[:maximum_service_instances]
    )

    invoke(
      'hosts:terminate',
      [
        region, asg_name, ecs_cluster_name, initial_hosts.map(&:id),
        host_cluster, service_cluster
      ]
    )

    invoke(
      'hosts:contract',
      [
        region, asg_name, ecs_cluster_name,
        host_cluster, service_cluster
      ]
    )

    invoke(
      'services:contract',
      [
        region, asg_name, ecs_cluster_name,
        service_cluster
      ],
      minimum_instances: options[:minimum_service_instances]
    )
  end
  # rubocop:enable Metrics/BlockLength
  say("Instances in host cluster #{host_cluster.name} rolled " \
      'successfully.')
end

#versionObject



24
25
26
# File 'lib/rollo/commands/main.rb', line 24

def version
  say Rollo::VERSION
end