azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az vmss reimage --ids parse error on v 2.45

Open marchesir opened this issue 3 years ago • 10 comments

hi,

sinsce upgrade from v2.44 to v2.45 the following errors are now happneing

command executed: az vmss reimage --ids /subscriptions/XXXX/resourceGroups/XXXX/providers/Microsoft.Compute/virtualMachineScaleSets/XXXX/virtualMachines/9999

before { "azure-cli": "2.44.1", "azure-cli-core": "2.44.1", "azure-cli-telemetry": "1.0.8", "extensions": {} }

after { "azure-cli": "2.45.0", "azure-cli-core": "2.45.0", "azure-cli-telemetry": "1.0.8", "extensions": {} }

error message: (InvalidParameter) The provided instanceId 9 is not an active Virtual Machine Scale Set VM instanceId. Code: InvalidParameter Message: The provided instanceId 9 is not an active Virtual Machine Scale Set VM instanceId. Target: instanceIds

seems to be reading only the first number char of the number.

OS: Ubuntu 20.04.5 LTS

marchesir avatar Mar 01 '23 11:03 marchesir

@zhoxing-ms for awareness

yonzhan avatar Mar 01 '23 13:03 yonzhan

@marchesir Could you please send the debug log (add --debug parameter) to me? My email address is [email protected]

zhoxing-ms avatar Mar 02 '23 02:03 zhoxing-ms

azclidebug.txt

hi @zhoxing-ms iv attached the debug log but have redacted account info but not insatnce id

what i can see is this:

cli.knack.cli: Command arguments: ['vmss', 'reimage', '--ids', '/subscriptions/XXXX/resourceGroups/XXXX/providers/Microsoft.Compute/virtualMachineScaleSets/XXXX/virtualMachines/100', '--no-wait', '--debug']

so 100 is passed in but when the azure api call is made it is cutting the 100 from the requst:

cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/XXXX/resourceGroups/XXXX/providers/Microsoft.Compute/virtualMachineScaleSets/XXXX/virtualMachines/1/reimage?api-version=2022-11-01' cli.azure.cli.core.sdk.policies: Request method: 'POST' cli.azure.cli.core.sdk.policies: Request headers: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json' cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'e3631833-b8ee-11ed-a79d-65179efe07a4' cli.azure.cli.core.sdk.policies: 'CommandName': 'vmss reimage' cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--ids --no-wait --debug' cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.45.0 (DEB) azsdk-python-azure-mgmt-compute/29.1.0 Python/3.10.8 (Linux-5.15.0-1033-azure-x86_64-with-glibc2.31)'

thanks

marchesir avatar Mar 02 '23 12:03 marchesir

@marchesir Please note that the --ids parameter should pass in the resource id of VMSS instead of the resource id of VM instance. If you need to specify the VM instance id, you should use parameter --instance-ids, such as:

az vmss reimage --instance-ids 100 --ids {VMSS_resource_id}

zhoxing-ms avatar Mar 03 '23 07:03 zhoxing-ms

Hi @marchesir. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost avatar Mar 03 '23 09:03 ghost

"/unresolve" hi @zhoxing-ms i am passing in the full resource id, this works perfect on v2.44 without any code updates but breaks on v2.45.

here iam passing the full resource id az vmss reimage --ids /subscriptions/XXXX/resourceGroups/XXXX/providers/Microsoft.Compute/virtualMachineScaleSets/XXXX/virtualMachines/9999

as can be seen in the logs its cutting instance number, iv tried with double quotes ("") but the same issue.

i know i can use --instance-ids to pass just the number and yes this works fine on both versions but i need the full resource id option.

  1. this is a clear bug that needs addressing
  2. i have workaround by using v2.44
  3. my current codebase uses full resource id to avoid complex parsing

its not my call but for now i will pin my codebase to v2.44 but hopfully this issue will be resolved and i can upgrade at some point. if the azure cli has updates the way full resource id is passed fine but iv checked the change logs and cant seee anyhting mentioned.

this is not urgent as i have a workaround if you need more input from me please reach out.

marchesir avatar Mar 03 '23 09:03 marchesir

@marchesir Sorry, I can't reproduce this issue in my local environment at present In fact, I found that if the --ids is a VM instance id under a VMSS, CLI will directly reimage the entire VMSS with ignoring the VM instance id. For example:

cli.knack.cli: Command arguments: ['vmss', 'reimage', '--ids', '/subscriptions/{subscription_id}/resourceGroups/zhoxing-test/providers/Microsoft.Compute/virtualMachineScaleSets/zhoxing-test/virtualMachines/100', '--debug']
...
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/zhoxing-test/providers/Microsoft.Compute/virtualMachineScaleSets/zhoxing-test/reimage?api-version=2022-11-01'

So the behavior of my local environment is different from what you described, I'm not sure whether it is caused by some differences in our usage.

Could you please provide me with the complete debug logs for CLI version 2.45.0 and 2.44.1? If you are concerned about the sensitive information, please send them to me by email, My email address is [email protected], Thank you In addition, if you use a script to execute this CLI command, please also send this script to me, thanks~

zhoxing-ms avatar Mar 06 '23 10:03 zhoxing-ms

hi @zhoxing-ms

iv attached 2 logs with all commands ran on each version, iv retacted some account info as this is being run inside a coperate environment.

so the commands are not run as indiviual user:

  1. ssh into vm on Azure VMSS
  2. az login to managed identity
  3. get vm respource id
  4. run reimage command

all i can see im running 100% same setup only difference id the azure cli version. the az cli is being run on azure vm.

all these details can be seen in the logs:

using v2.44.1 --> works fine azcli_good.txt

using v2.45.0 --> has parsing errror azcli_error.txt

so v2.45.0 clearly is cutting part of the instance id, not sure why, havent updated anything apart from azure cli unless the cli depends on something external within the OS.

so what i can see in logs is this: cli.knack.cli: Command arguments: ['vmss', 'reimage', '--ids', '/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss}/virtualMachines/107', '--no-wait', '--debug']

This looks good and then when the API call is made its been cut cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss}/virtualMachines/1/reimage?api-version=2022-11-01'

thanks again for help

marchesir avatar Mar 06 '23 14:03 marchesir

@marchesir Sorry, I still cannot reproduce your problem after referring to your process. The behavior of cutting instance id is strange, this command had not added similar logic before.

In version 2.45.0, only one PR #25131 has modified the logic of az vmss reimage command, but it does not seem to be related to this issue

Could you please upgrade CLI to the latest version 2.46.0 and try again?

zhoxing-ms avatar Mar 08 '23 07:03 zhoxing-ms

hi @zhoxing-ms thanks for update, so i tried v2.46 and works fine so will close issue. no idea what was causing it. thanks for you help much appreciated. im guessing was an edge case but what was causing it will remain a mystery

marchesir avatar Mar 10 '23 12:03 marchesir