Skip to content

Commit

Permalink
Clarify when node_locations is overriden
Browse files Browse the repository at this point in the history
If zones is not explicitly set for nodepools, it will inherit
whatever is set for the cluster itself. This makes the code
clearer so that is more obvious.

Fixes 2i2c-org#2769
  • Loading branch information
yuvipanda committed Jul 7, 2023
1 parent 1aac5c8 commit 21b1708
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions terraform/gcp/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ resource "google_container_node_pool" "notebook" {
location = google_container_cluster.cluster.location
version = var.k8s_versions.notebook_nodes_version

node_locations = length(each.value.zones) == 0 ? [var.zone] : each.value.zones

# terraform treats null same as unset, so we only set the node_locations
# here if it is explicitly overriden. If not, it will just inherit whatever
# is set for the cluster.
node_locations = length(each.value.zones) == 0 ? null : each.value.zones

initial_node_count = each.value.min
autoscaling {
Expand Down Expand Up @@ -344,7 +346,11 @@ resource "google_container_node_pool" "dask_worker" {
location = google_container_cluster.cluster.location
version = var.k8s_versions.dask_nodes_version

node_locations = length(each.value.zones) == 0 ? [var.zone] : each.value.zones
# terraform treats null same as unset, so we only set the node_locations
# here if it is explicitly overriden. If not, it will just inherit whatever
# is set for the cluster.
node_locations = length(each.value.zones) == 0 ? null : each.value.zones

# Default to same config as notebook nodepools config
for_each = var.dask_nodes

Expand Down

0 comments on commit 21b1708

Please sign in to comment.