Skip to content

Commit

Permalink
Add rollout option to osconfig patch deployment fixes hashicorp/terra…
Browse files Browse the repository at this point in the history
…form-provider-google#7124 (#3919)

* Add rollout option to osconfig patch deployment

* Add test

* Set properties to required and correctly specify exactly one of

* Fix typos
  • Loading branch information
cookejames authored Sep 1, 2020
1 parent 297beba commit a4f4f78
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
37 changes: 37 additions & 0 deletions products/osconfig/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,43 @@ objects:
One day of the month. 1-31 indicates the 1st to the 31st day. -1 indicates the last day of the month.
Months without the target day will be skipped. For example, a schedule to run "every month on the 31st"
will not run in February, April, June, etc.
- !ruby/object:Api::Type::NestedObject
name: 'rollout'
description: |
Rollout strategy of the patch job.
properties:
- !ruby/object:Api::Type::Enum
name: 'mode'
description: |
Mode of the patch rollout.
values:
- :ZONE_BY_ZONE
- :CONCURRENT_ZONES
required: true
- !ruby/object:Api::Type::NestedObject
name: 'disruptionBudget'
description: |
The maximum number (or percentage) of VMs per zone to disrupt at any given moment. The number of VMs calculated from multiplying the percentage by the total number of VMs in a zone is rounded up.
During patching, a VM is considered disrupted from the time the agent is notified to begin until patching has completed. This disruption time includes the time to complete reboot and any post-patch steps.
A VM contributes to the disruption budget if its patching operation fails either when applying the patches, running pre or post patch steps, or if it fails to respond with a success notification before timing out. VMs that are not running or do not have an active agent do not count toward this disruption budget.
For zone-by-zone rollouts, if the disruption budget in a zone is exceeded, the patch job stops, because continuing to the next zone requires completion of the patch process in the previous zone.
For example, if the disruption budget has a fixed value of 10, and 8 VMs fail to patch in the current zone, the patch job continues to patch 2 VMs at a time until the zone is completed. When that zone is completed successfully, patching begins with 10 VMs at a time in the next zone. If 10 VMs in the next zone fail to patch, the patch job stops.
properties:
- !ruby/object:Api::Type::Integer
name: fixed
description: |
Specifies a fixed value.
exactly_one_of:
- rollout.0.disruption_budget.0.fixed
- rollout.0.disruption_budget.0.percentage
- !ruby/object:Api::Type::Integer
name: percentage
description: |
Specifies the relative value defined as a percentage, which will be multiplied by a reference value.
exactly_one_of:
- rollout.0.disruption_budget.0.fixed
- rollout.0.disruption_budget.0.percentage
required: true
- !ruby/object:Api::Resource
name: 'GuestPolicies'
base_url: "projects/{{project}}/guestPolicies"
Expand Down
6 changes: 6 additions & 0 deletions products/osconfig/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
function: 'validation.IntBetween(-1,31)'
recurringSchedule.frequency: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
rollout.disruptionBudget.percentage: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntBetween(0,100)'
rollout.disruptionBudget.fixed: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntAtLeast(1)'
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/set_computed_name.erb
encoder: templates/terraform/encoders/os_config_patch_deployment.go.erb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,11 @@ resource "google_os_config_patch_deployment" "<%= ctx[:primary_resource_id] %>"
}
}
}

rollout {
mode = "ZONE_BY_ZONE"
disruption_budget {
fixed = 1
}
}
}

0 comments on commit a4f4f78

Please sign in to comment.