Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"--enable-nested" option doesn't work expectedly #7200

Open
yuriwoof opened this issue Jan 19, 2024 · 1 comment
Open

"--enable-nested" option doesn't work expectedly #7200

yuriwoof opened this issue Jan 19, 2024 · 1 comment
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/vm-repair question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone

Comments

@yuriwoof
Copy link

yuriwoof commented Jan 19, 2024

Describe the bug

It is possible to create repair VM but Hyper-V is not enabled.
I see #7177 (the result is slightly different).

  • Debug Log
$ az vm repair create -g labnestedvm -n nestedvm --repair-username azureuser --repair-password 'password!234' --enable-nested --verbose
Does repair vm requires public ip? (y/n): y
Fetching architecture type of the source VM...
Fetching compatible Windows OS images from gallery...
Fetching available VM sizes for repair VM...
VM size 'Standard_D2s_v3' is available. Using it to create repair VM.

Checking for existing resource groups with identical name within subscription...
Pre-existing repair resource group with the same name is 'False'
Creating resource group for repair VM and its resources...
Source VM uses managed disks. Creating repair VM with managed disks.

Copying OS disk of source VM...
Creating repair VM with command: az vm create -g repair-nestedvm-20240119062313 -n repair-nestedv_ --tag repair_source=labnestedvm/nestedvm --image MicrosoftWindowsServer:WindowsServer:2016-Datacenter:2016.127.20190416 --admin-username azureuser --admin-password password!234 --public-ip-address repair-nestedv_PublicIP --size Standard_D2s_v3
copy_disk_id: /subscriptions/93b7ca88-d2cc-4381-97ec-f99f3a702495/resourceGroups/labnestedvm/providers/Microsoft.Compute/disks/nestedvm-DiskCopy-20240119062313
repair_password: password!234
repair_username: azureuser
fix_uuid: False
Validating VM template before continuing...
Creating repair VM...
Running Script win-enable-nested-hyperv.ps1 to install HyperV

Your repair VM 'repair-nestedv_' has been created in the resource group 'repair-nestedvm-20240119062313' with disk 'nestedvm-DiskCopy-20240119062313' attached as data disk. Please use this VM to troubleshoot and repair. Once the repairs are complete use the command 'az vm repair restore -n nestedvm -g labnestedvm --verbose' to restore disk to the source VM. Note that the copied disk is created within the original resource group 'labnestedvm'.

{
  "copied_disk_name": "nestedvm-DiskCopy-20240119062313",
  "copied_disk_uri": "/subscriptions/xxx/resourceGroups/labnestedvm/providers/Microsoft.Compute/disks/nestedvm-DiskCopy-20240119062313",
  "created_resources": [
    "/subscriptions/xxx/resourceGroups/repair-nestedvm-20240119062313/providers/Microsoft.Network/networkInterfaces/repair-nestedv_VMNic",
    "/subscriptions/xxx/resourceGroups/REPAIR-NESTEDVM-20240119062313/providers/Microsoft.Compute/disks/repair-nestedv__disk1_5a57aca448c04a1083bfa06ea0e7d7a6",
    "/subscriptions/xxxresourceGroups/repair-nestedvm-20240119062313/providers/Microsoft.Network/publicIPAddresses/repair-nestedv_PublicIP",
    "/subscriptions/xxx/resourceGroups/repair-nestedvm-20240119062313/providers/Microsoft.Network/networkSecurityGroups/repair-nestedv_NSG",
    "/subscriptions/xxx/resourceGroups/repair-nestedvm-20240119062313/providers/Microsoft.Network/virtualNetworks/repair-nestedv_VNET",
    "/subscriptions/xxx/resourceGroups/repair-nestedvm-20240119062313/providers/Microsoft.Compute/virtualMachines/repair-nestedv_",
    "/subscriptions/xxx/resourceGroups/labnestedvm/providers/Microsoft.Compute/disks/nestedvm-DiskCopy-20240119062313"
  ],
  "message": "Your repair VM 'repair-nestedv_' has been created in the resource group 'repair-nestedvm-20240119062313' with disk 'nestedvm-DiskCopy-20240119062313' attached as data disk. Please use this VM to troubleshoot and repair. Once the repairs are complete use the command 'az vm repair restore -n nestedvm -g labnestedvm --verbose' to restore disk to the source VM. Note that the copied disk is created within the original resource group 'labnestedvm'.",
  "repair_resource_group": "repair-nestedvm-20240119062313",
  "repair_vm_name": "repair-nestedv_",
  "resource_tag": "repair_source=labnestedvm/nestedvm",
  "status": "SUCCESS"
}
Command ran in 346.562 seconds (init: 0.206, invoke: 346.355)
yuri@Azure:~$ 

I believe "az vm repair run" will be executed via custom script, but I confirm there is no event.

if enable_nested:
logger.info("Running Script win-enable-nested-hyperv.ps1 to install HyperV")
run_hyperv_command = "az vm repair run -g {g} -n {name} --run-id win-enable-nested-hyperv --parameters gen={gen}" \
.format(g=repair_group_name, name=repair_vm_name, gen=vm_hypervgen)
ret_enable_nested = _call_az_command(run_hyperv_command)
logger.debug("az vm repair run hyperv command returned: %s", ret_enable_nested)
if str.find(ret_enable_nested, "SuccessRestartRequired") > -1:
restart_cmd = 'az vm restart -g {rg} -n {vm}'.format(rg=repair_group_name, vm=repair_vm_name)
logger.info("Restarting Repair VM")
restart_ret = _call_az_command(restart_cmd)
logger.debug(restart_ret)
# invoking hyperv script again
logger.info("Running win-enable-nested-hyperv.ps1 again to create nested VM")
run_hyperv_command = "az vm repair run -g {g} -n {name} --run-id win-enable-nested-hyperv --parameters gen={gen}" \
.format(g=repair_group_name, name=repair_vm_name, gen=vm_hypervgen)
ret_enable_nested_again = _call_az_command(run_hyperv_command)
logger.debug("stderr: %s", ret_enable_nested_again)
created_resources = _list_resource_ids_in_rg(repair_group_name)
command.set_status_success()

Related command

How to reproduce.

$ az group create -n labnestedvm -l japaneast
$ az vm create -g labnestedvm --name nestedvm --image Win2022AzureEditionCore --admin-username azureuser --public-ip-address ""
$ az extension add -n vm-repair
$ az vm repair create -g labnestedvm -n nestedvm --repair-username azureuser --repair-password 'password!234' --enable-nested --verbose

Errors

No error. From debug log, enabling Hyper-V could be skipped.


Running Script win-enable-nested-hyperv.ps1 to install HyperV

Your repair VM 'repair-nestedv_' has been created in the resource group 'repair-nestedvm-20240119062313' with disk 'nestedvm-DiskCopy-20240119062313' attached as data disk. Please use this VM to troubleshoot and repair. Once the repairs are complete use the command 'az vm repair restore -n nestedvm -g labnestedvm --verbose' to restore disk to the source VM. Note that the copied disk is created within the original resource group 'labnestedvm'.

Issue script & Debug output

Please see entire debug log at "Describe the bug"

Expected behavior

Enabled Hyper-V described in below document.

https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/repair-windows-vm-using-azure-virtual-machine-repair-commands#repair-process-example

If you need to troubleshoot your VM in a nested Hyper-V environment, use --enable-nested and the repair VM will created with the Hyper-V role enabled along with a nested VM using the OS disk copy.

Environment Summary

$ az version
{
"azure-cli": "2.56.0",
"azure-cli-core": "2.56.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {
"vm-repair": "1.0.0b1"
}
}

Same in Azure Cloud Shell

Additional context

No response

@yuriwoof yuriwoof added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Jan 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. Compute labels Jan 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team labels Jan 19, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Jan 19, 2024

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added this to the Backlog milestone Jan 19, 2024
@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/vm-repair question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants