Skip to content

patch empty zone list return from command. - #40

Open
rajsinghtech wants to merge 1 commit into
mainfrom
patch-availability-zone
Open

patch empty zone list return from command.#40
rajsinghtech wants to merge 1 commit into
mainfrom
patch-availability-zone

Conversation

@rajsinghtech

Copy link
Copy Markdown

Due to the az command being ran here, an empty set of data retruns as an empty string "" instead of [].

│ Error: Error in function call
│ 
│   on .terraform/modules/aks/main.tf line 37, in module "main":
│   37:   agents_availability_zones         = sort(flatten(jsondecode(module.availability_zones_data_source.stdout)))
│     ├────────────────
│     │ while calling jsondecode(str)
│     │ module.availability_zones_data_source.stdout is ""
│ 
│ Call to function "jsondecode" failed: EOF.

@rajsinghtech rajsinghtech added the bug Something isn't working label Sep 3, 2024
@rajsinghtech rajsinghtech self-assigned this Sep 3, 2024
@PhilipSchmid

Copy link
Copy Markdown
Contributor

Have you tried manually running the az command from here? I don't see how this should return "". I get the following for example:

$ az vm list-skus --location westeurope --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc
[
  [
    "3",
    "2",
    "1"
  ]
]

How does your var.instance_type and var.region look like? What did you configure?

@rajsinghtech

Copy link
Copy Markdown
Author

Hmmm, looks like im setting region useast and setting Standard_D2s_v3 for var.worker_instance_type per template repo. Not setting var.instance_type specifically.

@PhilipSchmid

Copy link
Copy Markdown
Contributor

By not setting var.instance_type, it should take its default value, Standard_D2s_v3.

@PhilipSchmid

Copy link
Copy Markdown
Contributor

The template repo maps var.worker_instance_type to instance_type. Hence, you're setting it.

See https://github.com/isovalent/cute-template-repo/blob/099c1bc874f912b71076acee219922b3603a059f/azure-aks-byocni/aks.tf#L11C3-L11C49

@PhilipSchmid

Copy link
Copy Markdown
Contributor

It seems like there are no Standard_D2s_v3 VMs available in useast:

az vm list-skus --location useast --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc
[]

Still, STDOUT shows a proper [] and no "" 🤔. Maybe matti/resource/shell sees [] as an "empty string"? 🤷
Anyhow, I just also saw https://github.com/matti/terraform-shell-resource shouldn't be used anymore. Perhaps we should anyway rework this module part.

@rajsinghtech

Copy link
Copy Markdown
Author
 az vm list-skus --location useast --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc   

JSON is invalid: Unterminated string starting at: line 1 column 44885501 (char 44885500)

@rajsinghtech

Copy link
Copy Markdown
Author

My az cli must be broken locally?

@darox

darox commented Jan 15, 2025

Copy link
Copy Markdown
Contributor

can we close this? @rajsinghtech

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants