astronomer / astro-cli

CLI that makes it easy to create, test and deploy Airflow DAGs to Astronomer
https://www.astronomer.io
Other
362 stars 71 forks source link

CLI error when no nodepools discovered #1701

Open fjmacagno opened 3 months ago

fjmacagno commented 3 months ago

Describe the bug

In CI we sync a local deployment configuration to Astronomer, and are getting errors running the command

astro deployment update <id> --deployment-file .astro/astro_deployment_template.yaml

We have this line in the config: default_worker_type: m5.xlarge we get the error

Error: worker_type: m5.xlarge does not exist in cluster: aw-usw1-astronomer

If we remove the line, we get

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/astronomer/astro-cli/cloud/deployment/fromfile.getNodePoolIDFromWorkerType({0x0?, 0x12?}, {0x140006b6b70?, 0x103838f6b?}, {0x0?, 0x102df919c?, 0x140005c9088?})
github.com/astronomer/astro-cli/cloud/deployment/fromfile/fromfile.go:820 +0x78
github.com/astronomer/astro-cli/cloud/deployment/fromfile.createOrUpdateDeployment(0x140000f61a0, {0x140005a2240, 0x19}, {0x140005a2200, 0x1b}, {0x103831adf, 0x6}, 0x140005cb0c8, {0x0, 0x0, ...}, ...)
github.com/astronomer/astro-cli/cloud/deployment/fromfile/fromfile.go:628 +0x18e4
github.com/astronomer/astro-cli/cloud/deployment/fromfile.CreateOrUpdate({0x16d322f9e, 0x25}, {0x103848959, 0x6}, {0x103e19780, 0x1400028ad10}, {0x103e20700, 0x1400028acf0}, {0x103df6398, 0x1400007e050})
github.com/astronomer/astro-cli/cloud/deployment/fromfile/fromfile.go:172 +0x93c
github.com/astronomer/astro-cli/cmd/cloud.deploymentUpdate(0x14000010c08, {0x140000dc420, 0x1, 0x0?}, {0x103df6398, 0x1400007e050})
github.com/astronomer/astro-cli/cmd/cloud/deployment.go:745 +0x8f0
github.com/astronomer/astro-cli/cmd/cloud.newDeploymentUpdateCmd.func1(0x14000010c08?, {0x140000dc420?, 0x4?, 0x10382fbed?})
github.com/astronomer/astro-cli/cmd/cloud/deployment.go:430 +0x28
github.com/spf13/cobra.(*Command).execute(0x14000010c08, {0x140000dc3c0, 0x3, 0x3})
github.com/spf13/[cobra@v1.7.0](mailto:cobra@v1.7.0)/command.go:940 +0x654
github.com/spf13/cobra.(*Command).ExecuteC(0x140001cdb08)
github.com/spf13/[cobra@v1.7.0](mailto:cobra@v1.7.0)/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(0x103e0f3a0?)
github.com/spf13/[cobra@v1.7.0](mailto:cobra@v1.7.0)/command.go:992 +0x1c
main.main()
github.com/astronomer/astro-cli/main.go:21 +0x38

We have fixed the issue by adding deployment_type: DEDICATED to our deployment, but it seems like there should be a check in the cli for the case where there are no discovered nodepools, which is my guess as to what was happening. https://github.com/astronomer/astro-cli/blob/2a30180476c0e94dc90e5744498f00f240f83e91/cloud/deployment/fromfile/fromfile.go#L828

What CLI Version did you experience this bug? 1.28.1

This CLI bug is related to which Astronomer Platform?

What Operating System is the above CLI installed on?

🪜 Steps To Reproduce

📸 Screenshots