Skip to content

fix: handle null undrainable_node_behavior in precondition validation#763

Open
lonegunmanb wants to merge 3 commits intomainfrom
fix/issue-760-undrainable-null-validation
Open

fix: handle null undrainable_node_behavior in precondition validation#763
lonegunmanb wants to merge 3 commits intomainfrom
fix/issue-760-undrainable-null-validation

Conversation

@lonegunmanb
Copy link
Copy Markdown
Member

Fix

Resolves #760

Problem

When undrainable_node_behavior is explicitly set to null inside upgrade_settings for extra node pools, terraform plan crashes with:

Error: Invalid function argument contains(list, value) Invalid value for "value" parameter: argument must not be null.

Root Cause

In extra_node_pool.tf lines 183 and 350, the precondition uses:

condition = ... || contains(["Cordon", "Schedule"], try(each.value.upgrade_settings.undrainable_node_behavior, ""))

Two Terraform behaviors combine to cause this:

  1. try() passes null through — accessing a null-valued attribute is not an error, so try(null, "") returns null, not "".
  2. Terraform does not short-circuit || — all operands are evaluated before computing the logical result, so contains() receives null even though an earlier clause would make the expression true.

Fix

Wrap with coalesce() to convert null to "" before passing to contains():

contains(["Cordon", "Schedule"], coalesce(try(each.value.upgrade_settings.undrainable_node_behavior, ""), ""))

Also hardened a similar theoretical edge case in main.tf (blob driver subnet service endpoint check).

Changes

  • extra_node_pool.tf: Fix null-safety in precondition on lines 183 and 350 (both node_pool_create_before_destroy and node_pool_create_after_destroy)
  • main.tf: Harden service_endpoints null-safety in blob driver check (line 748)

The contains() function in Terraform does not accept null arguments,
and Terraform does not short-circuit || evaluation. When
undrainable_node_behavior is explicitly set to null, try() passes
null through (since accessing a null attribute is not an error), causing
contains() to crash with 'argument must not be null'.

Fix by wrapping with coalesce() to convert null to an empty string
before passing to contains(). Also harden the blob driver subnet
check in main.tf with the same pattern.

Fixes #760

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lonegunmanb lonegunmanb force-pushed the fix/issue-760-undrainable-null-validation branch from 9b0e388 to 3980c7d Compare May 7, 2026 05:52
…gress example

Zone 2 is not supported for AKS node pools in westeurope. Change to zone 3
which is the only supported zone for this region.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ilability

The australiasoutheast region hits Total Regional Cores quota limits
(Required: 12, Limit: 10). Switch to eastus which has sufficient quota.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

undrainable_node_behavior validation fails when set to null

1 participant