Skip to content

Conversation

@jepio
Copy link
Member

@jepio jepio commented Jan 18, 2022

Description

Some image aliases require "plan information" when used. The "Flatcar" alias is one of those. When usingan image URN, the validator fetches plan information and appends to the request, but this was missing when using an alias. Add the same handling to alias validation, so that aliases can be used as is without extra work from the user.

Testing Guide

g=group$RANDOM
az group create -g $g -l westeurope
az vm create -g $g -n vm$RANDOM --image Flatcar

Before this PR this results in an error ("missing plan information"), after this PR the result is success.

History Notes

[Compute] Fix #20174: az vm create: Determine plan information when using image alias


This checklist is used to make sure that common guidelines for a pull request are followed.

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 18, 2022

Compute

@yonzhan yonzhan added this to the Jan 2022 (2022-02-08) milestone Jan 18, 2022
@wangzelin007 wangzelin007 changed the title [Compute] az vm create: Determine plan information when using image alias (#20174) [Compute] Fix #20174: az vm create: Determine plan information when using image alias Jan 18, 2022
@wangzelin007
Copy link
Member

Hi jepio,
Could you merge the latest code from remote dev branch first. After that, we will help you solve the remaining CI issue later.

@jepio jepio force-pushed the jepio/alias-fix-plan branch from bbbb4e2 to aa5dcf3 Compare January 24, 2022 10:20
@ghost ghost added the Compute az vm/vmss/image/disk/snapshot label Jan 24, 2022
@ghost ghost requested a review from yonzhan January 24, 2022 10:20
@jepio
Copy link
Member Author

jepio commented Jan 24, 2022

I've rebased onto the remote dev branch. The test failures look like they test for a hard-coded sequence of remote operations, and would need updating.

@wangzelin007
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Some marketplace images require plan information to be provided when creating a
virtual machine. Missing plan information results in the error message:

  "Creating a virtual machine from Marketplace image or a custom image sourced from a Marketplace image requires Plan information in the request."

The "Flatcar" alias is one such case where plan information is needed.  When an
image is provided as a URN, the validator code takes care of determining the
plan information and filling it in, but when using an alias no such action is
taken.

Perform the same lookup when using an alias, so that users can use the alias as
intended and don't have to manually supply plan information.

Signed-off-by: Jeremi Piotrowski <[email protected]>
@jepio jepio force-pushed the jepio/alias-fix-plan branch from aa5dcf3 to ffbee38 Compare January 24, 2022 15:09
@jepio
Copy link
Member Author

jepio commented Jan 24, 2022

@wangzelin007 OK, now I understand. I updated the dev branch now.

@wangzelin007
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@wangzelin007
Copy link
Member

Hi @jepio,
The real reason is that add _get_image_plan_info_if_exists will add one more api call.
All involved tests need to be re-recorded and re-upload
image

@jepio
Copy link
Member Author

jepio commented Jan 25, 2022

OK, how do I re-record the tests?

@wangzelin007
Copy link
Member

wangzelin007 commented Jan 25, 2022

OK, how do I re-record the tests?
I am trying to re-record these tests, but many of them still failed in re-run.
image

get all failed test case in profile 2018-03-01-hybrid
azdev test vm --repo=./ --src=HEAD --tgt=origin/dev --no-exitfirst --profile 2018-03-01-hybrid --verbose --series
re-run error cases to generate recording files:
azdev test vm --no-exitfirst --live --lf --profile 2018-03-01-hybrid

get all failed test case in profile 2019-03-01-hybrid
azdev test vm --repo=./ --src=HEAD --tgt=origin/dev --no-exitfirst --profile 2019-03-01-hybrid --verbose --series
re-run error cases to generate recording files:
azdev test vm --no-exitfirst --live --lf --profile 2019-03-01-hybrid

get all failed test case in profile 2020-09-01-hybrid
azdev test vm --repo=./ --src=HEAD --tgt=origin/dev --no-exitfirst --profile 2020-09-01-hybrid --verbose --series
re-run error cases to generate recording files:
azdev test vm --no-exitfirst --live --lf --profile 2020-09-01-hybrid

get all failed test case in profile latest
azdev test vm --repo=./ --src=HEAD --tgt=origin/dev --no-exitfirst --profile latest --verbose --series
re-run error cases to generate recording files:
azdev test vm --no-exitfirst --live --lf --profile latest

@ghost ghost added the Auto-Assign Auto assign by bot label Jan 27, 2022
if enable_hibernation is not None:
vm_properties['additionalCapabilities']['hibernationEnabled'] = enable_hibernation
if enable_hibernation is not None:
vm_properties['additionalCapabilities']['hibernationEnabled'] = enable_hibernation
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
additionalCapabilities

self.cmd('vm get-instance-view -n {vm} -g {rg}', checks=[
self.check('*.extensions[0].name', ['VMAccessForLinux']),
self.check('*.extensions[0].typeHandlerVersion', ['1.4.7.1'])
self.check('*.extensions[0].typeHandlerVersion', ['1.5.11'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
1 4 7 1


class VMBootDiagnostics(ScenarioTest):

@AllowLargeResponse()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
AllowLargeResponse

vm_properties = {'hardwareProfile': {'vmSize': size, 'vmSizeProperties': vm_size_properties},
'networkProfile': {'networkInterfaces': nics}, 'storageProfile': _build_storage_profile()}
if vm_size_properties:
vm_properties['hardwareProfile']['vmSizeProperties'] = vm_size_properties
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

{
  "status": "Failed",
  "error": {
    "code": "DeploymentFailed",
    "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
    "details": [
      {
        "code": "BadRequest",
        "message": {
          "error": {
            "details": [
              {
                "message": "Could not find member vmSizeProperties on object of type VMHardwareProfile. Path properties.hardwareProfile.vmSizeProperties, line 1, position 110.",
                "target": "vm.properties.hardwareProfile.vmSizeProperties"
              },
              {
                "message": "Could not find member additionalCapabilities on object of type Properties. Path properties.additionalCapabilities, line 1, position 1230.",
                "target": "vm.properties.additionalCapabilities"
              }
            ],
            "code": "BadRequest",
            "message": "The request message is invalid."
          }
        }
      }
    ]
  }
}

})

self.cmd('vm create -n {vm} -g {rg} --image openSUSE-Leap --admin-username user11 --private-ip-address 10.0.0.5 --public-ip-sku {public_ip_sku} --public-ip-address-dns-name {dns} --generate-ssh-keys')
self.cmd('vm create -n {vm} -g {rg} --image UbuntuLTS --admin-username user11 --private-ip-address 10.0.0.5 --public-ip-sku {public_ip_sku} --public-ip-address-dns-name {dns} --generate-ssh-keys')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
ImageNotFound2


# verify the default should be "Basic" sku with "Dynamic" allocation method
self.cmd('vm create -n {vm2} -g {rg} --image openSUSE-Leap --admin-username user11 --generate-ssh-keys')
self.cmd('vm create -n {vm2} -g {rg} --image UbuntuLTS --admin-username user11 --generate-ssh-keys')
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


class VMSSCreateAndModify(ScenarioTest):

@AllowLargeResponse()
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

'vmss': 'vmss1'
})
self.cmd("vmss create -n {vmss} -g {rg} --vm-sku Standard_DS4_v2 --image Win2022Datacenter --admin-username clittester --admin-password Test12345678!!! --accelerated-networking --instance-count 1")
self.cmd("vmss create -n {vmss} -g {rg} --vm-sku Standard_DS4_v2 --image Win2012R2Datacenter --admin-username clittester --admin-password Test12345678!!! --accelerated-networking --instance-count 1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
Win2022Datacenter

Copy link
Contributor

@zhoxing-ms zhoxing-ms Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using image Win2022Datacenter is by design for TLS 1.2 compliant, PR link: #20701, I think we need to investigate the reason why this image can no longer be found

@@ -1077,6 +1077,7 @@ def test_vm_create_none_options(self, resource_group):

class VMBootDiagnostics(ScenarioTest):

@AllowLargeResponse()
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -1343,7 +1344,7 @@ def test_vm_create_custom_ip(self, resource_group):
'public_ip_sku': 'Standard'
})

self.cmd('vm create -n {vm} -g {rg} --image openSUSE-Leap --admin-username user11 --private-ip-address 10.0.0.5 --public-ip-sku {public_ip_sku} --public-ip-address-dns-name {dns} --generate-ssh-keys')
self.cmd('vm create -n {vm} -g {rg} --image UbuntuLTS --admin-username user11 --private-ip-address 10.0.0.5 --public-ip-sku {public_ip_sku} --public-ip-address-dns-name {dns} --generate-ssh-keys')
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -1354,7 +1355,7 @@ def test_vm_create_custom_ip(self, resource_group):
checks=self.check('ipConfigurations[0].privateIpAllocationMethod', 'Static'))

# verify the default should be "Basic" sku with "Dynamic" allocation method
self.cmd('vm create -n {vm2} -g {rg} --image openSUSE-Leap --admin-username user11 --generate-ssh-keys')
self.cmd('vm create -n {vm2} -g {rg} --image UbuntuLTS --admin-username user11 --generate-ssh-keys')
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -1490,6 +1491,7 @@ def test_vm_create_custom_data(self, resource_group):

class VMSSCreateAndModify(ScenarioTest):

@AllowLargeResponse()
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -2130,7 +2132,7 @@ def test_vm_error_on_zone_unavailable(self, resource_group, resource_group_locat
try:
self.cmd('vm create -g {rg} -n vm1 --admin-username clitester --admin-password PasswordPassword1! --image debian --zone 1')
except Exception as ex:
self.assertTrue('availability zone is not yet supported' in str(ex))
self.assertTrue('does not support availability zones at location' in str(ex))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
AssertionError

@@ -905,6 +905,7 @@ def test_vm_create_existing_ids_options(self, resource_group, storage_account):

class VMSSCreateAndModify(ScenarioTest):

@AllowLargeResponse()
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -3992,7 +3992,7 @@ def test_vm_error_on_zone_unavailable(self, resource_group, resource_group_locat
try:
self.cmd('vm create -g {rg} -n vm1 --admin-username clitester --admin-password PasswordPassword1! --image debian --zone 1')
except Exception as ex:
self.assertTrue('availability zone is not yet supported' in str(ex))
self.assertTrue('does not support availability zones at location' in str(ex))
Copy link
Member

@wangzelin007 wangzelin007 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -6728,7 +6730,7 @@ def test_vmss_windows_patch_mode(self, resource_group):
'rg': resource_group
})

self.cmd('vmss create -g {rg} -n {vmss} --image Win2022Datacenter --enable-agent --enable-auto-update false --patch-mode Manual --orchestration-mode Flexible --admin-username azureuser --admin-password testPassword0')
self.cmd('vmss create -g {rg} -n {vmss} --image Win2012Datacenter --enable-agent --enable-auto-update false --patch-mode Manual --orchestration-mode Flexible --admin-username azureuser --admin-password testPassword0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -5367,31 +5367,33 @@ def test_dedicated_host_e2e(self, resource_group, resource_group_location):
self.cmd('vm delete --name vm2 -g {rg2} --yes')
self.cmd('vm host delete --name {host-name} --host-group {host-group} -g {rg2} --yes')

@ResourceGroupPreparer(name_prefix='cli_test_dedicated_host_', location='westus2')
@ResourceGroupPreparer(name_prefix='cli_test_dedicated_host3_', location='eastus2')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix
test_update_dedicated_host_e2e

@zhoxing-ms
Copy link
Contributor

Replaced by #21666

@zhoxing-ms zhoxing-ms closed this Mar 18, 2022
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 Compute az vm/vmss/image/disk/snapshot do-not-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az vm create fails for Flatcar distro alias because plan information is unset

4 participants