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

Adds support for Graceful Updater in Compute Managed Instance Groups. #5975

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,15 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
"minimal_action": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false),
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.`,
ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false),
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.`,
},

"most_disruptive_allowed_action": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false),
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.`,
},

"type": {
Expand Down Expand Up @@ -919,6 +926,12 @@ func expandUpdatePolicy(configured []interface{}) *compute.InstanceGroupManagerU
data := raw.(map[string]interface{})

updatePolicy.MinimalAction = data["minimal_action"].(string)
mostDisruptiveAllowedAction := data["most_disruptive_allowed_action"].(string)
if mostDisruptiveAllowedAction != "" {
updatePolicy.MostDisruptiveAllowedAction = mostDisruptiveAllowedAction
} else {
updatePolicy.NullFields = append(updatePolicy.NullFields, "MostDisruptiveAllowedAction")
}
updatePolicy.Type = data["type"].(string)
updatePolicy.ReplacementMethod = data["replacement_method"].(string)
<% unless version == "ga" -%>
Expand Down Expand Up @@ -1010,6 +1023,7 @@ func flattenUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdatePolicy)
up["min_ready_sec"] = updatePolicy.MinReadySec
<% end -%>
up["minimal_action"] = updatePolicy.MinimalAction
up["most_disruptive_allowed_action"] = updatePolicy.MostDisruptiveAllowedAction
up["type"] = updatePolicy.Type
up["replacement_method"] = updatePolicy.ReplacementMethod
results = append(results, up)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,15 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
"minimal_action": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"RESTART", "REPLACE"}, false),
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.`,
ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false),
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.`,
},

"most_disruptive_allowed_action": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false),
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.`,
},

"type": {
Expand Down Expand Up @@ -775,6 +782,12 @@ func expandRegionUpdatePolicy(configured []interface{}) *compute.InstanceGroupMa
data := raw.(map[string]interface{})

updatePolicy.MinimalAction = data["minimal_action"].(string)
mostDisruptiveAllowedAction := data["most_disruptive_allowed_action"].(string)
if mostDisruptiveAllowedAction != "" {
updatePolicy.MostDisruptiveAllowedAction = mostDisruptiveAllowedAction
} else {
updatePolicy.NullFields = append(updatePolicy.NullFields, "MostDisruptiveAllowedAction")
}
updatePolicy.Type = data["type"].(string)
updatePolicy.InstanceRedistributionType = data["instance_redistribution_type"].(string)
updatePolicy.ReplacementMethod = data["replacement_method"].(string)
Expand Down Expand Up @@ -838,6 +851,7 @@ func flattenRegionUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdateP
up["min_ready_sec"] = updatePolicy.MinReadySec
<% end -%>
up["minimal_action"] = updatePolicy.MinimalAction
up["most_disruptive_allowed_action"] = updatePolicy.MostDisruptiveAllowedAction
up["type"] = updatePolicy.Type
up["instance_redistribution_type"] = updatePolicy.InstanceRedistributionType
up["replacement_method"] = updatePolicy.ReplacementMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,10 +933,11 @@ resource "google_compute_instance_group_manager" "igm-rolling-update-policy" {
zone = "us-central1-c"
target_size = 3
update_policy {
type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_fixed = 2
max_unavailable_fixed = 2
type = "PROACTIVE"
minimal_action = "REPLACE"
most_disruptive_allowed_action = "REPLACE"
max_surge_fixed = 2
max_unavailable_fixed = 2
}
named_port {
name = "customhttp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1295,15 +1295,16 @@ resource "google_compute_region_instance_group_manager" "igm-rolling-update-poli
distribution_policy_zones = ["us-central1-a", "us-central1-f"]
target_size = 3
update_policy {
type = "PROACTIVE"
instance_redistribution_type = "NONE"
minimal_action = "REPLACE"
gsancewicz marked this conversation as resolved.
Show resolved Hide resolved
max_surge_fixed = 0
max_unavailable_fixed = 2
type = "PROACTIVE"
instance_redistribution_type = "NONE"
minimal_action = "REPLACE"
most_disruptive_allowed_action = "REPLACE"
max_surge_fixed = 0
max_unavailable_fixed = 2
<% unless version == "ga" -%>
min_ready_sec = 10
min_ready_sec = 10
<% end -%>
replacement_method = "RECREATE"
replacement_method = "RECREATE"
}
named_port {
name = "customhttp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ group. You can specify only one value. Structure is [documented below](#nested_a

```hcl
update_policy {
type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_percent = 20
max_unavailable_fixed = 2
min_ready_sec = 50
replacement_method = "RECREATE"
type = "PROACTIVE"
minimal_action = "REPLACE"
most_disruptive_allowed_action = "REPLACE"
max_surge_percent = 20
max_unavailable_fixed = 2
min_ready_sec = 50
replacement_method = "RECREATE"
}
```

* `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.
* `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.
gsancewicz marked this conversation as resolved.
Show resolved Hide resolved

* `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.

* `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).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,20 @@ group. You can specify one or more values. For more information, see the [offici

```hcl
update_policy {
type = "PROACTIVE"
instance_redistribution_type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_percent = 20
max_unavailable_fixed = 2
min_ready_sec = 50
replacement_method = "RECREATE"
type = "PROACTIVE"
instance_redistribution_type = "PROACTIVE"
minimal_action = "REPLACE"
most_disruptive_allowed_action = "REPLACE"
max_surge_percent = 20
max_unavailable_fixed = 2
min_ready_sec = 50
replacement_method = "RECREATE"
}
```

* `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.
* `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.

* `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.

* `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).

Expand Down