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

Azure: Problems with disk_additional_size on images containg already additional disks #7042

Closed
loibpet opened this issue Nov 26, 2018 · 4 comments

Comments

@loibpet
Copy link

loibpet commented Nov 26, 2018

packer -v: 1.3.2

We are using for our images a "chained" process for on-premis and for all cloud providers, i.e. we create one basis containing all required hardening, company specific setup and cloud specific configuration. Then we use this basis in another step and create the intended image flavor. In step one, we create one additional disk to separate the /var/log tree to a separate disk (company way of doing things which cannot be changed). For certain use cases, we need to use one more data disk in the image (e.g. for local data storage).

Our templates look like this:

Step 1:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "image_publisher": "OpenLogic",
            "image_offer": "CentOS",
            "image_sku": "7.5",
            "image_version": "latest",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                5
            ],
            "managed_image_name": "packer-test-step1",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

This works fine and the image is created as needed.

Step 2 - Version 1:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "custom_managed_image_name": "packer-test-step1",
            "custom_managed_image_resource_group_name": "my-rg",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                10
            ],
            "managed_image_name": "packer-test-step2a",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

This one fails with:

==> azure-arm: ERROR: -> BadRequest

==> azure-arm: ERROR: -> InvalidParameter : Cannot specify user image overrides for a disk already defined in the specified image reference.

Step 2 - Version 2:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "custom_managed_image_name": "packer-test-step1",
            "custom_managed_image_resource_group_name": "my-rg",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                5, 10
            ],
            "managed_image_name": "packer-test-step2b",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

Adding the size of the user disk of step 1 fails as well:

==> azure-arm: ERROR: -> BadRequest

==> azure-arm: ERROR: -> InvalidParameter : Cannot specify user image overrides for a disk already defined in the specified image reference.

@boumenot
Copy link
Collaborator

Based on the error message it looks like Packer is allowing a configuration that is not supported by Azure. @loibpet, is this your belief too, or do you think it should work and Packer is not sending the correct configuration to Azure?

@loibpet
Copy link
Author

loibpet commented Dec 3, 2018

Being in the Azure portal (https://portal.azure.com/):

  1. Select image from "step1" and click in "Create VM"
  2. Enter all required information and proceed to "Disks"
  3. Upon clicking "Create and attach a new disk", I am able to create and attach as many new disks as I like/need

Therefore, my expectation is that packer is able to add as many new disks as needed in step 2. This is working fine if done manually through the Azure portal (I haven't tried so far through the command line).

@jforest
Copy link

jforest commented Dec 5, 2018

I'm running into what I think is the same thing. The base image I'm using has a data disk attached, and I need to create a VHD based image because that is what azure requires to sell VMs on the marketplace.

Anyway, if I don't specify disk_additional_size The errors I see are:

==> azure-arm: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
==> azure-arm: ERROR:   -> BadRequest
==> azure-arm: ERROR:   -> InvalidParameter : StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.
==> azure-arm:
==> azure-arm: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details." Details=[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"InvalidParameter\",\r\n    \"message\": \"StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.\",\r\n    \"target\": \"storageProfile\"\r\n  }\r\n}"}]
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.

and if I DO specify disk_additional_size I get THIS set of errors

==> azure-arm: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
==> azure-arm: ERROR:   -> BadRequest
==> azure-arm: ERROR:   -> InvalidParameter : Cannot specify user image overrides for a disk already defined in the specified image reference.
==> azure-arm:
==> azure-arm: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details." Details=[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"InvalidParameter\",\r\n    \"message\": \"Cannot specify user image overrides for a disk already defined in the specified image reference.\",\r\n    \"target\": \"storageProfile\"\r\n  }\r\n}"}]
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.

It feels to me that one or the other should work.

Also, FWIW it seems I can create a managed image based on the same base image, without issue. So it's just a VHD related error.

@ghost
Copy link

ghost commented Apr 30, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-azure#18 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-azure#18.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants