Skip to content

Commit 32b6889

Browse files
Support new features of IGM.updatePolicy (#4956) (#4235)
* Add new IGM.UpdatePolicy features - minimal_action=REFRESH and most_disruptive_allowed_action * Fix documentation of most_disruptive_allowed_action * Make most_disruptive_allowed_action an Optional field. * Fix RMIG UpdatePolicy flattening. * Fix most_disruptive_allowed_action documentation - new field is Optional. * Fix most_disruptive_allowed_action documentation - and improve testing. * Fix whitespaces in test. Co-authored-by: Grzegorz Sancewicz <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Grzegorz Sancewicz <[email protected]>
1 parent 4905c47 commit 32b6889

7 files changed

+62
-30
lines changed

.changelog/4956.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:enhancement
2+
compute: added field `update_policy.most_disruptive_allowed_action` to `google_compute_instance_group_manager` and `google_compute_region_instance_group_manager`
3+
```
4+
```release-note:enhancement
5+
compute: added value `REFRESH` to field update_policy.minimal_action` in `google_compute_instance_group_manager` and `google_compute_region_instance_group_manager`
6+
```

google-beta/resource_compute_instance_group_manager.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,15 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
201201
"minimal_action": {
202202
Type: schema.TypeString,
203203
Required: true,
204-
ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false),
205-
Description: `Minimal action to be taken on an instance. You can specify either RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a RESTART, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`,
204+
ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false),
205+
Description: `Minimal action to be taken on an instance. You can specify either REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`,
206+
},
207+
208+
"most_disruptive_allowed_action": {
209+
Type: schema.TypeString,
210+
Optional: true,
211+
ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false),
212+
Description: `Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all.`,
206213
},
207214

208215
"type": {
@@ -912,6 +919,7 @@ func expandUpdatePolicy(configured []interface{}) *compute.InstanceGroupManagerU
912919
data := raw.(map[string]interface{})
913920

914921
updatePolicy.MinimalAction = data["minimal_action"].(string)
922+
updatePolicy.MostDisruptiveAllowedAction = data["most_disruptive_allowed_action"].(string)
915923
updatePolicy.Type = data["type"].(string)
916924
updatePolicy.ReplacementMethod = data["replacement_method"].(string)
917925
updatePolicy.MinReadySec = int64(data["min_ready_sec"].(int))
@@ -999,6 +1007,7 @@ func flattenUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdatePolicy)
9991007
}
10001008
up["min_ready_sec"] = updatePolicy.MinReadySec
10011009
up["minimal_action"] = updatePolicy.MinimalAction
1010+
up["most_disruptive_allowed_action"] = updatePolicy.MostDisruptiveAllowedAction
10021011
up["type"] = updatePolicy.Type
10031012
up["replacement_method"] = updatePolicy.ReplacementMethod
10041013
results = append(results, up)

google-beta/resource_compute_instance_group_manager_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,11 @@ resource "google_compute_instance_group_manager" "igm-rolling-update-policy" {
932932
zone = "us-central1-c"
933933
target_size = 3
934934
update_policy {
935-
type = "PROACTIVE"
936-
minimal_action = "REPLACE"
937-
max_surge_fixed = 2
938-
max_unavailable_fixed = 2
935+
type = "PROACTIVE"
936+
minimal_action = "REPLACE"
937+
most_disruptive_allowed_action = "REPLACE"
938+
max_surge_fixed = 2
939+
max_unavailable_fixed = 2
939940
}
940941
named_port {
941942
name = "customhttp"

google-beta/resource_compute_region_instance_group_manager.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,15 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
239239
"minimal_action": {
240240
Type: schema.TypeString,
241241
Required: true,
242-
ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false),
243-
Description: `Minimal action to be taken on an instance. You can specify either RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a RESTART, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`,
242+
ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false),
243+
Description: `Minimal action to be taken on an instance. You can specify either REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`,
244+
},
245+
246+
"most_disruptive_allowed_action": {
247+
Type: schema.TypeString,
248+
Optional: true,
249+
ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false),
250+
Description: `Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all.`,
244251
},
245252

246253
"type": {
@@ -768,6 +775,7 @@ func expandRegionUpdatePolicy(configured []interface{}) *compute.InstanceGroupMa
768775
data := raw.(map[string]interface{})
769776

770777
updatePolicy.MinimalAction = data["minimal_action"].(string)
778+
updatePolicy.MostDisruptiveAllowedAction = data["most_disruptive_allowed_action"].(string)
771779
updatePolicy.Type = data["type"].(string)
772780
updatePolicy.InstanceRedistributionType = data["instance_redistribution_type"].(string)
773781
updatePolicy.ReplacementMethod = data["replacement_method"].(string)
@@ -827,6 +835,7 @@ func flattenRegionUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdateP
827835
}
828836
up["min_ready_sec"] = updatePolicy.MinReadySec
829837
up["minimal_action"] = updatePolicy.MinimalAction
838+
up["most_disruptive_allowed_action"] = updatePolicy.MostDisruptiveAllowedAction
830839
up["type"] = updatePolicy.Type
831840
up["instance_redistribution_type"] = updatePolicy.InstanceRedistributionType
832841
up["replacement_method"] = updatePolicy.ReplacementMethod

google-beta/resource_compute_region_instance_group_manager_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,13 +1294,14 @@ resource "google_compute_region_instance_group_manager" "igm-rolling-update-poli
12941294
distribution_policy_zones = ["us-central1-a", "us-central1-f"]
12951295
target_size = 3
12961296
update_policy {
1297-
type = "PROACTIVE"
1298-
instance_redistribution_type = "NONE"
1299-
minimal_action = "REPLACE"
1300-
max_surge_fixed = 0
1301-
max_unavailable_fixed = 2
1302-
min_ready_sec = 10
1303-
replacement_method = "RECREATE"
1297+
type = "PROACTIVE"
1298+
instance_redistribution_type = "NONE"
1299+
minimal_action = "REPLACE"
1300+
most_disruptive_allowed_action = "REPLACE"
1301+
max_surge_fixed = 0
1302+
max_unavailable_fixed = 2
1303+
min_ready_sec = 10
1304+
replacement_method = "RECREATE"
13041305
}
13051306
named_port {
13061307
name = "customhttp"

website/docs/r/compute_instance_group_manager.html.markdown

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,19 @@ group. You can specify only one value. Structure is [documented below](#nested_a
149149

150150
```hcl
151151
update_policy {
152-
type = "PROACTIVE"
153-
minimal_action = "REPLACE"
154-
max_surge_percent = 20
155-
max_unavailable_fixed = 2
156-
min_ready_sec = 50
157-
replacement_method = "RECREATE"
152+
type = "PROACTIVE"
153+
minimal_action = "REPLACE"
154+
most_disruptive_allowed_action = "REPLACE"
155+
max_surge_percent = 20
156+
max_unavailable_fixed = 2
157+
min_ready_sec = 50
158+
replacement_method = "RECREATE"
158159
}
159160
```
160161

161-
* `minimal_action` - (Required) - Minimal action to be taken on an instance. You can specify either `RESTART` to restart existing instances or `REPLACE` to delete and create new instances from the target template. If you specify a `RESTART`, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.
162+
* `minimal_action` - (Required) - Minimal action to be taken on an instance. You can specify either `REFRESH` to update without stopping instances, `RESTART` to restart existing instances or `REPLACE` to delete and create new instances from the target template. If you specify a `REFRESH`, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.
163+
164+
* `most_disruptive_allowed_action` - (Optional) - Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all.
162165

163166
* `type` - (Required) - The type of update process. You can specify either `PROACTIVE` so that the instance group manager proactively executes actions in order to bring instances to their target versions or `OPPORTUNISTIC` so that no action is proactively executed but the update will be performed as part of other actions (for example, resizes or recreateInstances calls).
164167

website/docs/r/compute_region_instance_group_manager.html.markdown

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,20 @@ group. You can specify one or more values. For more information, see the [offici
158158

159159
```hcl
160160
update_policy {
161-
type = "PROACTIVE"
162-
instance_redistribution_type = "PROACTIVE"
163-
minimal_action = "REPLACE"
164-
max_surge_percent = 20
165-
max_unavailable_fixed = 2
166-
min_ready_sec = 50
167-
replacement_method = "RECREATE"
161+
type = "PROACTIVE"
162+
instance_redistribution_type = "PROACTIVE"
163+
minimal_action = "REPLACE"
164+
most_disruptive_allowed_action = "REPLACE"
165+
max_surge_percent = 20
166+
max_unavailable_fixed = 2
167+
min_ready_sec = 50
168+
replacement_method = "RECREATE"
168169
}
169170
```
170171

171-
* `minimal_action` - (Required) - Minimal action to be taken on an instance. You can specify either `RESTART` to restart existing instances or `REPLACE` to delete and create new instances from the target template. If you specify a `RESTART`, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.
172+
* `minimal_action` - (Required) - Minimal action to be taken on an instance. You can specify either `REFRESH` to update without stopping instances, `RESTART` to restart existing instances or `REPLACE` to delete and create new instances from the target template. If you specify a `REFRESH`, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.
173+
174+
* `most_disruptive_allowed_action` - (Optional) - Most disruptive action that is allowed to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to allow actions that do not need instance restart, RESTART to allow actions that can be applied without instance replacing or REPLACE to allow all possible actions. If the Updater determines that the minimal update action needed is more disruptive than most disruptive allowed action you specify it will not perform the update at all.
172175

173176
* `type` - (Required) - The type of update process. You can specify either `PROACTIVE` so that the instance group manager proactively executes actions in order to bring instances to their target versions or `OPPORTUNISTIC` so that no action is proactively executed but the update will be performed as part of other actions (for example, resizes or recreateInstances calls).
174177

0 commit comments

Comments
 (0)