Class: EcsDeploy::AutoScaler::SpotFleetRequestConfig
- Inherits:
-
Struct
- Object
- Struct
- EcsDeploy::AutoScaler::SpotFleetRequestConfig
- Includes:
- ConfigBase
- Defined in:
- lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#disable_draining ⇒ Object
Returns the value of attribute disable_draining.
-
#id ⇒ Object
Returns the value of attribute id.
-
#region ⇒ Object
Returns the value of attribute region.
-
#service_configs ⇒ Object
Returns the value of attribute service_configs.
Instance Method Summary collapse
- #cluster_resource_manager ⇒ Object
-
#initialize(attributes = {}, logger) ⇒ SpotFleetRequestConfig
constructor
A new instance of SpotFleetRequestConfig.
- #name ⇒ Object
- #update_desired_capacity(required_capacity) ⇒ Object
Methods included from ConfigBase
Constructor Details
#initialize(attributes = {}, logger) ⇒ SpotFleetRequestConfig
Returns a new instance of SpotFleetRequestConfig.
14 15 16 17 18 19 20 21 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 14 def initialize(attributes = {}, logger) attributes = attributes.dup services = attributes.delete("services") super(attributes, logger) self.service_configs = services.map do |s| ServiceConfig.new(s.merge("cluster" => cluster, "region" => region), logger) end end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def buffer @buffer end |
#cluster ⇒ Object
Returns the value of attribute cluster
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def cluster @cluster end |
#disable_draining ⇒ Object
Returns the value of attribute disable_draining
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def disable_draining @disable_draining end |
#id ⇒ Object
Returns the value of attribute id
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def id @id end |
#region ⇒ Object
Returns the value of attribute region
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def region @region end |
#service_configs ⇒ Object
Returns the value of attribute service_configs
11 12 13 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 11 def service_configs @service_configs end |
Instance Method Details
#cluster_resource_manager ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 51 def cluster_resource_manager @cluster_resource_manager ||= EcsDeploy::AutoScaler::ClusterResourceManager.new( region: region, cluster: cluster, service_configs: service_configs, capacity_based_on: "vCPUs", logger: @logger, ) end |
#name ⇒ Object
23 24 25 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 23 def name id end |
#update_desired_capacity(required_capacity) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ecs_deploy/auto_scaler/spot_fleet_request_config.rb', line 27 def update_desired_capacity(required_capacity) terminate_orphan_instances desired_capacity = (required_capacity + buffer.to_f).ceil request_config = ec2_client.describe_spot_fleet_requests( spot_fleet_request_ids: [id] ).spot_fleet_request_configs[0].spot_fleet_request_config return if desired_capacity == request_config.target_capacity ec2_client.modify_spot_fleet_request(spot_fleet_request_id: id, target_capacity: desired_capacity) cluster_resource_manager.trigger_capacity_update( request_config.target_capacity, desired_capacity, # Wait until the capacity is updated to prevent the process from terminating before container draining is completed wait_until_capacity_updated: desired_capacity < request_config.target_capacity, ) @logger.info "#{log_prefix} Updated desired_capacity to #{desired_capacity}" rescue => e AutoScaler.error_logger.error(e) end |