Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add field maintenance_window.start_time to google_compute_node_group #509

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/resources/google_compute_node_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Properties that can be accessed from the `google_compute_node_group` resource:

* `maintenance_policy`: Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT.

* `maintenance_window`: contains properties for the timeframe of maintenance

* `start_time`: instances.start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid.

* `autoscaling_policy`: If you use sole-tenant nodes for your workloads, you can use the node group autoscaler to automatically manage the sizes of your node groups.

* `mode`: The autoscaling mode. Set to one of the following: - OFF: Disables the autoscaler. - ON: Enables scaling in and scaling out. - ONLY_SCALE_OUT: Enables only scaling out. You must use this mode if your node groups are configured to restart their hosted VMs on minimal servers.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_node_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ See [google_compute_node_group.md](google_compute_node_group.md) for more detail
* `node_templates`: an array of `google_compute_node_group` node_template
* `sizes`: an array of `google_compute_node_group` size
* `maintenance_policies`: an array of `google_compute_node_group` maintenance_policy
* `maintenance_windows`: an array of `google_compute_node_group` maintenance_window
* `autoscaling_policies`: an array of `google_compute_node_group` autoscaling_policy
* `zones`: an array of `google_compute_node_group` zone

Expand Down
34 changes: 34 additions & 0 deletions libraries/google/compute/property/nodegroup_maintenance_window.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 NodeGroupMaintenanceWindow
attr_reader :start_time

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

def to_s
"#{@parent_identifier} NodeGroupMaintenanceWindow"
end
end
end
end
end
3 changes: 3 additions & 0 deletions libraries/google_compute_node_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/compute/property/nodegroup_autoscaling_policy'
require 'google/compute/property/nodegroup_maintenance_window'

# A provider to manage Compute Engine resources.
class ComputeNodeGroup < GcpResourceBase
Expand All @@ -29,6 +30,7 @@ class ComputeNodeGroup < GcpResourceBase
attr_reader :node_template
attr_reader :size
attr_reader :maintenance_policy
attr_reader :maintenance_window
attr_reader :autoscaling_policy
attr_reader :zone

Expand All @@ -46,6 +48,7 @@ def parse
@node_template = @fetched['nodeTemplate']
@size = @fetched['size']
@maintenance_policy = @fetched['maintenancePolicy']
@maintenance_window = GoogleInSpec::Compute::Property::NodeGroupMaintenanceWindow.new(@fetched['maintenanceWindow'], to_s)
@autoscaling_policy = GoogleInSpec::Compute::Property::NodeGroupAutoscalingPolicy.new(@fetched['autoscalingPolicy'], to_s)
@zone = @fetched['zone']
end
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_node_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ComputeNodeGroups < GcpResourceBase
filter_table_config.add(:node_templates, field: :node_template)
filter_table_config.add(:sizes, field: :size)
filter_table_config.add(:maintenance_policies, field: :maintenance_policy)
filter_table_config.add(:maintenance_windows, field: :maintenance_window)
filter_table_config.add(:autoscaling_policies, field: :autoscaling_policy)
filter_table_config.add(:zones, field: :zone)

Expand Down Expand Up @@ -76,6 +77,7 @@ def transformers
'nodeTemplate' => ->(obj) { return :node_template, obj['nodeTemplate'] },
'size' => ->(obj) { return :size, obj['size'] },
'maintenancePolicy' => ->(obj) { return :maintenance_policy, obj['maintenancePolicy'] },
'maintenanceWindow' => ->(obj) { return :maintenance_window, GoogleInSpec::Compute::Property::NodeGroupMaintenanceWindow.new(obj['maintenanceWindow'], to_s) },
'autoscalingPolicy' => ->(obj) { return :autoscaling_policy, GoogleInSpec::Compute::Property::NodeGroupAutoscalingPolicy.new(obj['autoscalingPolicy'], to_s) },
'zone' => ->(obj) { return :zone, obj['zone'] },
}
Expand Down