Skip to content

Multiple errors due to hcl errors #5070

@ovesh

Description

@ovesh

If you find a similar existing issue, please comment on that issue instead of creating a new one.

If you are submitting a feature request, please start a discussion instead of creating an issue.

Describe the bug

I tried following the instructions on https://docs.cloud.google.com/ai-hypercomputer/docs/create/gke-ai-hypercompute
I cloned cluster-toolkit and built it locally. I got 3 separate errors in modules.

scheduler/gke-cluster

Error: Invalid function argument

 on modules/embedded/modules/scheduler/gke-cluster/variables.tf line 120, in variable "maintenance_exclusions":
120:         (x.end_time == null || length(trimspace(x.end_time)) > 0)
   ├────────────────
   │ x.end_time is null

This is due to this condition in the for loop not being interpreted as you would suspect (hcl doesn't short-circuit based on conditional values).

for x in var.maintenance_exclusions : (
  ((x.end_time != null) != (x.exclusion_end_time_behavior != null)) &&
  (x.end_time == null || length(trimspace(x.end_time)) > 0)
)

file-system/cloud-storage-bucket

 Error: Attempt to get attribute from null value

  on modules/embedded/modules/file-system/cloud-storage-bucket/main.tf line 122, in resource "google_storage_bucket" "bucket":
 122:         for zone in var.anywhere_cache.zones : startswith(zone, var.region)
    ├────────────────
    │ var.anywhere_cache is null

This value is null, so it does not have any attributes. 

This fails due to a similar bug, the condition not being short circuited:

  condition = var.anywhere_cache == null || alltrue([
    for zone in try(var.anywhere_cache.zones, []) : startswith(zone, var.region)
  ])

management/kubectl-apply/kubectl

Error: Error in function call

  on modules/embedded/modules/management/kubectl-apply/kubectl/main.tf line 50, in locals:
  50:         can(yamldecode(content)) && length(yamldecode(content)) > 0 ? content : null

Call to function "yamldecode" failed: on line 1, column 1: missing start of
document.

This also happens due to lack of short-circuiting.

Steps to reproduce

Steps to reproduce the behavior:

  1. Clone the repo
  2. make
  3. Edit examples/gke-a4/gke-a4-deployment.yaml to set some values
  4. ./gcluster deploy -d examples/gke-a4/gke-a4-deployment.yaml examples/gke-a4/gke-a4.yaml

Expected behavior

The deployment dir is created with the tf files

Actual behavior

Getting error messages.

Version (gcluster --version)

gcluster version - not built from official release
Built from 'main' branch.
Commit info: v1.76.0-1-ge6ac71d54-dirty
Terraform version: 1.9.8

Execution environment

  • OS: macOS
  • Shell: zsh
  • go version: go1.25.5 darwin/arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions