Skip to content

Commit 8e7afd9

Browse files
authored
fix: auto_provisioning_defaults not created when enable_default_compute_class=true and NAP disabled (#2547)
1 parent ca18dbc commit 8e7afd9

16 files changed

Lines changed: 32 additions & 24 deletions

File tree

autogen/main/cluster.tf.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ resource "google_container_cluster" "primary" {
164164
enabled = var.cluster_autoscaling.enabled
165165
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
166166
dynamic "auto_provisioning_defaults" {
167-
for_each = var.cluster_autoscaling.enabled ? [1] : []
167+
for_each = local.autoscaling_or_compute_class_enabled ? [1] : []
168168

169169
content {
170170
service_account = local.service_account
@@ -373,10 +373,10 @@ resource "google_container_cluster" "primary" {
373373

374374
{% if autopilot_cluster != true %}
375375
dynamic "node_pool_auto_config" {
376-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
376+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
377377
content {
378378
dynamic "network_tags" {
379-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
379+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
380380
content {
381381
tags = var.add_cluster_firewall_rules ? (concat(var.network_tags, [local.cluster_network_tag])) : var.network_tags
382382
}

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ locals {
6464
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
6565

6666
{% if autopilot_cluster != true %}
67+
autoscaling_or_compute_class_enabled = var.cluster_autoscaling.enabled || lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
6768
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
6869
resource_type = "cpu"
6970
minimum = var.cluster_autoscaling.min_cpu_cores

cluster.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ resource "google_container_cluster" "primary" {
131131
enabled = var.cluster_autoscaling.enabled
132132
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
133133
dynamic "auto_provisioning_defaults" {
134-
for_each = var.cluster_autoscaling.enabled ? [1] : []
134+
for_each = local.autoscaling_or_compute_class_enabled ? [1] : []
135135

136136
content {
137137
service_account = local.service_account
@@ -279,10 +279,10 @@ resource "google_container_cluster" "primary" {
279279
}
280280

281281
dynamic "node_pool_auto_config" {
282-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
282+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
283283
content {
284284
dynamic "network_tags" {
285-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
285+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
286286
content {
287287
tags = var.add_cluster_firewall_rules ? (concat(var.network_tags, [local.cluster_network_tag])) : var.network_tags
288288
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ locals {
5757
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
5858
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5959

60+
autoscaling_or_compute_class_enabled = var.cluster_autoscaling.enabled || lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
6061
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
6162
resource_type = "cpu"
6263
minimum = var.cluster_autoscaling.min_cpu_cores

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ resource "google_container_cluster" "primary" {
137137
enabled = var.cluster_autoscaling.enabled
138138
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
139139
dynamic "auto_provisioning_defaults" {
140-
for_each = var.cluster_autoscaling.enabled ? [1] : []
140+
for_each = local.autoscaling_or_compute_class_enabled ? [1] : []
141141

142142
content {
143143
service_account = local.service_account
@@ -292,10 +292,10 @@ resource "google_container_cluster" "primary" {
292292
}
293293

294294
dynamic "node_pool_auto_config" {
295-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
295+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
296296
content {
297297
dynamic "network_tags" {
298-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
298+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
299299
content {
300300
tags = var.add_cluster_firewall_rules ? (concat(var.network_tags, [local.cluster_network_tag])) : var.network_tags
301301
}

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ locals {
5757
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
5858
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5959

60+
autoscaling_or_compute_class_enabled = var.cluster_autoscaling.enabled || lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
6061
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
6162
resource_type = "cpu"
6263
minimum = var.cluster_autoscaling.min_cpu_cores

modules/beta-private-cluster/cluster.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ resource "google_container_cluster" "primary" {
137137
enabled = var.cluster_autoscaling.enabled
138138
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
139139
dynamic "auto_provisioning_defaults" {
140-
for_each = var.cluster_autoscaling.enabled ? [1] : []
140+
for_each = local.autoscaling_or_compute_class_enabled ? [1] : []
141141

142142
content {
143143
service_account = local.service_account
@@ -292,10 +292,10 @@ resource "google_container_cluster" "primary" {
292292
}
293293

294294
dynamic "node_pool_auto_config" {
295-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
295+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
296296
content {
297297
dynamic "network_tags" {
298-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
298+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
299299
content {
300300
tags = var.add_cluster_firewall_rules ? (concat(var.network_tags, [local.cluster_network_tag])) : var.network_tags
301301
}

modules/beta-private-cluster/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ locals {
5757
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
5858
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5959

60+
autoscaling_or_compute_class_enabled = var.cluster_autoscaling.enabled || lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
6061
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
6162
resource_type = "cpu"
6263
minimum = var.cluster_autoscaling.min_cpu_cores

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ resource "google_container_cluster" "primary" {
137137
enabled = var.cluster_autoscaling.enabled
138138
default_compute_class_enabled = lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
139139
dynamic "auto_provisioning_defaults" {
140-
for_each = var.cluster_autoscaling.enabled ? [1] : []
140+
for_each = local.autoscaling_or_compute_class_enabled ? [1] : []
141141

142142
content {
143143
service_account = local.service_account
@@ -292,10 +292,10 @@ resource "google_container_cluster" "primary" {
292292
}
293293

294294
dynamic "node_pool_auto_config" {
295-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
295+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || length(var.resource_manager_tags) > 0 || var.add_cluster_firewall_rules || local.node_pools_cgroup_mode != null) ? [1] : []
296296
content {
297297
dynamic "network_tags" {
298-
for_each = var.cluster_autoscaling.enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
298+
for_each = local.autoscaling_or_compute_class_enabled && (length(var.network_tags) > 0 || var.add_cluster_firewall_rules) ? [1] : []
299299
content {
300300
tags = var.add_cluster_firewall_rules ? (concat(var.network_tags, [local.cluster_network_tag])) : var.network_tags
301301
}

modules/beta-public-cluster-update-variant/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ locals {
5757
release_channel = var.release_channel != null ? [{ channel : var.release_channel }] : []
5858
gateway_api_config = var.gateway_api_channel != null ? [{ channel : var.gateway_api_channel }] : []
5959

60+
autoscaling_or_compute_class_enabled = var.cluster_autoscaling.enabled || lookup(var.cluster_autoscaling, "enable_default_compute_class", false)
6061
autoscaling_resource_limits = var.cluster_autoscaling.enabled ? concat([{
6162
resource_type = "cpu"
6263
minimum = var.cluster_autoscaling.min_cpu_cores

0 commit comments

Comments
 (0)