-
Notifications
You must be signed in to change notification settings - Fork 269
Description
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
When deploying the gke-a4 blueprint, [gcluster] fails with a yamldecode error in the kubectl-apply module. The error "missing start of document" indicates that yamldecode is being called on an empty or invalid string that can(yamldecode(...)) fails to guard against adequately (or yamldecode itself doesn't handle empty input gracefully even inside can in some terraform versions/contexts, or the expression evaluation order causes issues).
The issue seems to stem from modules/embedded/modules/management/kubectl-apply/kubectl/main.tf.
Steps to reproduce
Steps to reproduce the behavior:
- Use the
gke-a4example blueprint. - Run the deploy command:
./gcluster deploy -d examples/gke-a4/gke-a4-deployment.yaml examples/gke-a4/gke-a4.yaml
Expected behavior
The deployment should proceed past the infrastructure validation/initialization stage without Terraform errors.
Actual behavior
The deployment fails with multiple yamldecode errors:
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.
Version (gcluster --version)
gcluster version - not built from official release
Built from 'main' branch.
Commit info: v1.78.0-1-g1ea487b16
Blueprint
[examples/gke-a4/gke-a4-deployment.yaml]:
terraform_backend_defaults:
type: gcs
configuration:
bucket: gke_toolkit_storage
vars:
project_id: xxxxxxx-gke-dev
deployment_name: gke-a4-euw4
region: europe-west4
zone: europe-west4-b
static_node_count: 2
authorized_cidr: 0.0.0.0/0
spot: true
system_node_pool_disk_size_gb: 100
a4_node_pool_disk_size_gb: 500
enable_periodic_health_checks: true
health_check_schedule: "0 0 * * 0"[examples/gke-a4/gke-a4.yaml]:
(Standard example content for gke-a4 with spot reservation)
Expanded Blueprint
N/A
Output and logs
Creating deployment folder "gke-a4-euw4" ...
Initializing deployment group gke-a4-euw4/primary
Testing if deployment group gke-a4-euw4/primary requires adding or changing cloud infrastructure
Error: exit status 1
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.
Screenshots
N/A
Execution environment
- OS: Linux
- Shell: bash
- go version: go1.24.8 linux/amd64
Additional context
Attempted fix:
Modifying [modules/management/kubectl-apply/kubectl/main.tf] to explicit check for empty content or use try fixes the issue.
The fix that worked:
try(length(yamldecode(content)) > 0, false) ? content : nullInstead of:
can(yamldecode(content)) && length(yamldecode(content)) > 0 ? content : null