Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.61k stars 5.02k forks source link

[BUG] VM Extension typeHandlerVersion not showing the correct version #30107

Open Klaas- opened 1 month ago

Klaas- commented 1 month ago

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/virtualMachine.json

API Spec version

2024-07-01

Describe the bug

The response of typeHandlerVersion in VirtualMachineExtensionInstanceView and VirtualMachineExtension should be the same, this reflects the currently installed Extension Version -- or you need to change the definition of the one in VirtualMachineExtension to say "the version you specified when installing the extension" -- which is also not the version you actually install if you have autoUpgradeMinorVersion set to true :)

Expected behavior

VirtualMachineExtension typeHandlerVersion should either show a) the currently installed version or b) the version it was installed with (taking into account the auto upgrade minor=true)

Actual behavior

VirtualMachineExtension typeHandlerVersion shows the version you specifiy in the extension installation

Reproduction Steps

Install an extension to one of your existing virtual machines for example via ansible:

      azure_rm_virtualmachineextension:
        subscription_id: "{{ subscription_id }}"
        resource_group: "{{ resource_group_name }}"
        name: AzureMonitorLinuxAgent
        virtual_machine_name: "{{ inventory_hostname_short }}"
        publisher: Microsoft.Azure.Monitor
        virtual_machine_extension_type: AzureMonitorLinuxAgent
        type_handler_version: 1.0
        auto_upgrade_minor_version: true

Then get the extension including instanceVIew: https://management.azure.com/subscriptions/SUBSCRIPTION/resourceGroups/RESOURCEGROUP/providers/Microsoft.Compute/virtualMachines/VMNAME/extensions/AzureMonitorLinuxAgent?api-version=2024-07-01&$expand=InstanceView

Output will show:

{
[...]
  "properties": {
    "autoUpgradeMinorVersion": true,
[...]
    "instanceView": {
[...]
      "typeHandlerVersion": "1.31.1",
[...]
    },
[...]
    "typeHandlerVersion": "1.0"
  }
}

Environment

Production Azure

v-jiaodi commented 1 month ago

@grizzlytheodore Please help take a look, thanks.

GabstaMSFT commented 1 month ago

@Klaas-, when an extension publishes their extension version they use Major.Minor.Patch.Hotfix (1.0.0.0) versioning. When a customer installs an extension they are only able to specify the Major.Minor version to install, the platform will install the latest Patch.Hotfix version. With autoUpgradeMinorVersion set to "true" the platform will install the latest minor version, if it is set to "false" then it will only install to specified Major.Minor version.

{ [...] "properties": { "autoUpgradeMinorVersion": true, [...] "instanceView": { [...] "typeHandlerVersion": "1.31.1", <-- Instance view will show Major.Minor.Patch.Hotfix version. [...] }, [...] "typeHandlerVersion": "1.0" <-- Model view will only shows Major.Minor that was specified during install } }

Klaas- commented 1 month ago

Hi @GabstaMSFT so the problem here, from my point of view is primarily that both fields should include the same information: as per spec: https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-extensions/get?view=rest-compute-2024-07-01&tabs=HTTP#virtualmachineextension properties.typeHandlerVersion string Specifies the version of the script handler.

https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-extensions/get?view=rest-compute-2024-07-01&tabs=HTTP#virtualmachineextensioninstanceview typeHandlerVersion string Specifies the version of the script handler.

so one of the definitions is wrong? :)

What it currently does: one shows the version of I specified in the rest call, the other one shows the currently installed version Major.Minor.Patch

What it should do is up to you, but they can't have the same definition and show different output.

Now from a customer perspective, the version I specify in my deployment does not have much value, from your description I would say the non-instance-view typeHandlerVersion should show 1.31, and the instance-view one should show 1.13.1

and then you can change the definitions to "Specifies the full version of running the script handler." and the other one "Specifies the version of the installed script handler in Major.Minor format"