Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add ScaleInControl fields to GCE Autoscalers (#4147) (#471)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 10, 2020
1 parent 5cfceae commit e899f8f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/resources/google_compute_autoscaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ Properties that can be accessed from the `google_compute_autoscaler` resource:

* `time_window_sec`: How long back autoscaling should look when computing recommendations to include directives regarding slower scale down, as described above.

* `scale_in_control`: Defines scale in controls to reduce the risk of response latency and outages due to abrupt scale-in events

* `max_scaled_in_replicas`: A nested object resource

* `fixed`: Specifies a fixed number of VM instances. This must be a positive integer.

* `percent`: Specifies a percentage of instances between 0 to 100%, inclusive. For example, specify 80 for 80%.

* `time_window_sec`: How long back autoscaling should look when computing recommendations to include directives regarding slower scale down, as described above.

* `cpu_utilization`: Defines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group.

* `utilization_target`: The target CPU utilization that the autoscaler should maintain. Must be a float value in the range (0, 1]. If not specified, the default is 0.6. If the CPU level is below the target utilization, the autoscaler scales down the number of instances until it reaches the minimum number of instances you specified or until the average CPU of your instances reaches the target utilization. If the average CPU is above the target utilization, the autoscaler scales up until it reaches the maximum number of instances you specified or until the average utilization reaches the target utilization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
require 'google/compute/property/autoscaler_autoscaling_policy_load_balancing_utilization'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_down_control'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_down_control_max_scaled_down_replicas'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_in_control'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_in_control_max_scaled_in_replicas'
module GoogleInSpec
module Compute
module Property
Expand All @@ -32,6 +34,8 @@ class AutoscalerAutoscalingPolicy

attr_reader :scale_down_control

attr_reader :scale_in_control

attr_reader :cpu_utilization

attr_reader :custom_metric_utilizations
Expand All @@ -46,6 +50,7 @@ def initialize(args = nil, parent_identifier = nil)
@cool_down_period_sec = args['coolDownPeriodSec']
@mode = args['mode']
@scale_down_control = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyScaleDownControl.new(args['scaleDownControl'], to_s)
@scale_in_control = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyScaleInControl.new(args['scaleInControl'], to_s)
@cpu_utilization = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyCpuUtilization.new(args['cpuUtilization'], to_s)
@custom_metric_utilizations = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyCustomMetricUtilizationsArray.parse(args['customMetricUtilizations'], to_s)
@load_balancing_utilization = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyLoadBalancingUtilization.new(args['loadBalancingUtilization'], to_s)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/compute/property/autoscaler_autoscaling_policy_scale_in_control_max_scaled_in_replicas'
module GoogleInSpec
module Compute
module Property
class AutoscalerAutoscalingPolicyScaleInControl
attr_reader :max_scaled_in_replicas

attr_reader :time_window_sec

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@max_scaled_in_replicas = GoogleInSpec::Compute::Property::AutoscalerAutoscalingPolicyScaleInControlMaxScaledInReplicas.new(args['maxScaledInReplicas'], to_s)
@time_window_sec = args['timeWindowSec']
end

def to_s
"#{@parent_identifier} AutoscalerAutoscalingPolicyScaleInControl"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module Compute
module Property
class AutoscalerAutoscalingPolicyScaleInControlMaxScaledInReplicas
attr_reader :fixed

attr_reader :percent

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@fixed = args['fixed']
@percent = args['percent']
end

def to_s
"#{@parent_identifier} AutoscalerAutoscalingPolicyScaleInControlMaxScaledInReplicas"
end
end
end
end
end
2 changes: 2 additions & 0 deletions libraries/google_compute_autoscaler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
require 'google/compute/property/autoscaler_autoscaling_policy_load_balancing_utilization'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_down_control'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_down_control_max_scaled_down_replicas'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_in_control'
require 'google/compute/property/autoscaler_autoscaling_policy_scale_in_control_max_scaled_in_replicas'

# A provider to manage Compute Engine resources.
class ComputeAutoscaler < GcpResourceBase
Expand Down

0 comments on commit e899f8f

Please sign in to comment.