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

feat!: Allow setting predictive method for CPU utilization scaling #255

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ resource "google_compute_region_autoscaler" "autoscaler" {
dynamic "cpu_utilization" {
for_each = var.autoscaling_cpu
content {
target = lookup(cpu_utilization.value, "target", null)
target = lookup(cpu_utilization.value, "target", null)
predictive_method = lookup(cpu_utilization.value, "predictive_method", null)
}
}
dynamic "metric" {
Expand Down
5 changes: 4 additions & 1 deletion autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ variable "autoscaling_mode" {

variable "autoscaling_cpu" {
description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization"
type = list(map(number))
type = list(object({
target = number
predictive_method = string
}))
default = []
}

Expand Down
3 changes: 2 additions & 1 deletion examples/mig/healthcheck/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ module "mig" {

autoscaling_cpu = [
{
target = 0.4
target = 0.4
predictive_method = null # use default of NONE
},
]

Expand Down
2 changes: 1 addition & 1 deletion modules/mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The current version is 2.X. The following guides are available to assist with up
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| autoscaler\_name | Autoscaler name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no |
| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | `[]` | no |
| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | <pre>list(object({<br> target = number<br> predictive_method = string<br> }))</pre> | `[]` | no |
| autoscaling\_enabled | Creates an autoscaler for the managed instance group | `string` | `"false"` | no |
| autoscaling\_lb | Autoscaling, load balancing utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#load_balancing_utilization | `list(map(number))` | `[]` | no |
| autoscaling\_metric | Autoscaling, metric policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#metric | <pre>list(object({<br> name = string<br> target = number<br> type = string<br> }))</pre> | `[]` | no |
Expand Down
3 changes: 2 additions & 1 deletion modules/mig/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ resource "google_compute_region_autoscaler" "autoscaler" {
dynamic "cpu_utilization" {
for_each = var.autoscaling_cpu
content {
target = lookup(cpu_utilization.value, "target", null)
target = lookup(cpu_utilization.value, "target", null)
predictive_method = lookup(cpu_utilization.value, "predictive_method", null)
}
}
dynamic "metric" {
Expand Down
7 changes: 5 additions & 2 deletions modules/mig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ variable "autoscaling_mode" {

variable "autoscaling_cpu" {
description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization"
type = list(map(number))
default = []
type = list(object({
target = number
predictive_method = string
}))
default = []
}

variable "autoscaling_metric" {
Expand Down
2 changes: 1 addition & 1 deletion modules/mig_with_percent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The current version is 2.X. The following guides are available to assist with up
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| autoscaler\_name | Autoscaler name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no |
| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | `[]` | no |
| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | <pre>list(object({<br> target = number<br> predictive_method = string<br> }))</pre> | `[]` | no |
| autoscaling\_enabled | Creates an autoscaler for the managed instance group | `string` | `"false"` | no |
| autoscaling\_lb | Autoscaling, load balancing utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#load_balancing_utilization | `list(map(number))` | `[]` | no |
| autoscaling\_metric | Autoscaling, metric policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#metric | <pre>list(object({<br> name = string<br> target = number<br> type = string<br> }))</pre> | `[]` | no |
Expand Down
3 changes: 2 additions & 1 deletion modules/mig_with_percent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ resource "google_compute_region_autoscaler" "autoscaler" {
dynamic "cpu_utilization" {
for_each = var.autoscaling_cpu
content {
target = lookup(cpu_utilization.value, "target", null)
target = lookup(cpu_utilization.value, "target", null)
predictive_method = lookup(cpu_utilization.value, "predictive_method", null)
}
}
dynamic "metric" {
Expand Down
7 changes: 5 additions & 2 deletions modules/mig_with_percent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ variable "autoscaling_mode" {

variable "autoscaling_cpu" {
description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization"
type = list(map(number))
default = []
type = list(object({
target = number
predictive_method = string
}))
default = []
}

variable "autoscaling_metric" {
Expand Down