packer-cn/builder/azure/arm
Wilken Rivera afd33679f5 builder/azure_arm: Fix build failures due to the deletion of attached managed disks
Previously (prior to v1.6.2) the Azure ARM builder had two delete functions
one that would run before any of the StepDelete* types, and one on deployment template
cleanup. The refactored coded re-introduces the logic from the previously removed
step in v1.6.1 as the main delete logic for the whole deployment
template. Ensuring that all deployed items are deleted before trying to
remove any managed disks.

This change moves all the deletion logic into the
step_deployment_template#Cleanup function to ensure that dependent steps
are only called once the created deployment items (i.e
StepDelateAdditionalDisks) have been deleted.

Test results before change
```

    compute.DisksClient#Delete: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="OperationNotAllowed" Message="Disk pkrdd02e9rzzu5k-1 is attached to VM /subscriptions/1f90521a-24f6-4758-ac3d-88d869fb0bf5/resourceGroups/packer-acceptance-test/providers/Microsoft.Compute/virtualMachines/pkrvm02e9rzzu5k."
--- FAIL: TestBuilderAcc_ManagedDisk_Windows_Build_Resource_Group_Additional_Disk (454.00s)
FAIL
FAIL    github.com/hashicorp/packer/builder/azure/arm   454.008s

```

Test results after change
```
--- PASS: TestBuilderAcc_ManagedDisk_Windows_Build_Resource_Group_Additional_Disk (563.56s)

```

Closes #10070
2020-10-23 13:44:27 -04:00
..
TestVirtualMachineDeployment05.approved.txt Randomize osDisk name for Azure Managed Image builds. 2018-05-02 22:42:08 +02:00
artifact.go Sharing info with post-processors via artifact (#8632) 2020-01-30 11:27:58 +01:00
artifact_test.go Sharing info with post-processors via artifact (#8632) 2020-01-30 11:27:58 +01:00
azure_client.go Allows publishing to a Shared Image Gallery with a different subscription id (#9875) 2020-09-03 17:13:32 +02:00
azure_error_response.go azure: go vet ./... 2017-06-26 11:13:40 -07:00
azure_error_response_test.TestAzureErrorNestedShouldFormat.approved.txt Fix line ending issues for test files (#10096) 2020-10-14 11:03:43 +02:00
azure_error_response_test.TestAzureErrorSimpleShouldFormat.approved.txt Fix line ending issues for test files (#10096) 2020-10-14 11:03:43 +02:00
azure_error_response_test.go change Builder to be passed a context for cancellation 2019-04-03 15:55:55 +02:00
builder.go builder/azure_arm: Fix build failures due to the deletion of attached managed disks 2020-10-23 13:44:27 -04:00
builder_acc_test.go builder/azure_arm: Fix build failures due to the deletion of attached managed disks 2020-10-23 13:44:27 -04:00
builder_test.go Put the correct AzureTags type in StateBag (#10014) 2020-09-30 09:55:46 -04:00
capture_template.go Add support for optionally building Azure VMs with additional disks. 2018-02-23 15:34:13 -08:00
capture_template_test.go Add support for optionally building Azure VMs with additional disks. 2018-02-23 15:34:13 -08:00
config.go review comments, add plugin type for a few missing builders 2020-10-21 16:17:32 -07:00
config.hcl2spec.go azure arm: make map[string]*string => map[string]string to simplify things (#9985) 2020-09-24 12:19:26 +02:00
config_test.go Put the correct AzureTags type in StateBag (#10014) 2020-09-30 09:55:46 -04:00
inspector.go run goimports 2018-01-22 17:21:10 -08:00
openssh_key_pair.go also use config.SSHPrivateKey for azure-arm builds 2018-08-29 14:40:32 +02:00
openssh_key_pair_test.go run goimports 2018-01-22 17:21:10 -08:00
resource_resolver.go Updated go version and reformatted 2018-11-09 22:41:48 +00:00
resource_resolver_test.go build using HCL2 (#8423) 2019-12-17 11:25:56 +01:00
step.go Process review feedback 2018-05-04 00:28:34 +00:00
step_capture_image.go [builder/azure-arm] Use VM/build location for image location (#9068) 2020-04-17 05:43:03 -04:00
step_capture_image_test.go [builder/azure-arm] Use VM/build location for image location (#9068) 2020-04-17 05:43:03 -04:00
step_certificate_in_keyvault.go add tests 2020-02-06 16:41:28 -08:00
step_certificate_in_keyvault_test.go add tests 2020-02-06 16:41:28 -08:00
step_create_resource_group.go Put the correct AzureTags type in StateBag (#10014) 2020-09-30 09:55:46 -04:00
step_create_resource_group_test.go Put the correct AzureTags type in StateBag (#10014) 2020-09-30 09:55:46 -04:00
step_delete_additional_disks.go Handle lease not present error 2020-08-12 11:27:07 -04:00
step_delete_additional_disks_test.go make tests pass again 2018-05-01 15:39:50 +00:00
step_deploy_template.go builder/azure_arm: Fix build failures due to the deletion of attached managed disks 2020-10-23 13:44:27 -04:00
step_deploy_template_test.go rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +02:00
step_get_additional_disks.go Make it compile again 2018-05-01 15:39:50 +00:00
step_get_additional_disks_test.go make tests pass again 2018-05-01 15:39:50 +00:00
step_get_certificate.go rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +02:00
step_get_certificate_test.go test fixes WIP 2018-01-24 17:09:17 -08:00
step_get_ip_address.go Make it compile again 2018-05-01 15:39:50 +00:00
step_get_ip_address_test.go make tests pass again 2018-05-01 15:39:50 +00:00
step_get_os_disk.go Make it compile again 2018-05-01 15:39:50 +00:00
step_get_os_disk_test.go make tests pass again 2018-05-01 15:39:50 +00:00
step_power_off_compute.go Update Azure SDK for Go to v30.0.0 2019-05-30 21:25:43 +00:00
step_power_off_compute_test.go make tests pass again 2018-05-01 15:39:50 +00:00
step_publish_to_shared_image_gallery.go [builder/azure-arm] Use VM/build location for image location (#9068) 2020-04-17 05:43:03 -04:00
step_publish_to_shared_image_gallery_test.go Set expiry for image versions in SIG 2020-01-06 22:58:26 -08:00
step_set_certificate.go rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +02:00
step_set_certificate_test.go test fixes WIP 2018-01-24 17:09:17 -08:00
step_snapshot_data_disks.go Update Azure SDK for Go to v30.0.0 2019-05-30 21:25:43 +00:00
step_snapshot_data_disks_test.go change Builder to be passed a context for cancellation 2019-04-03 15:55:55 +02:00
step_snapshot_os_disk.go Update Azure SDK for Go to v30.0.0 2019-05-30 21:25:43 +00:00
step_snapshot_os_disk_test.go change Builder to be passed a context for cancellation 2019-04-03 15:55:55 +02:00
step_test.go Process review feedback 2018-05-04 00:28:34 +00:00
step_validate_template.go Make it compile again 2018-05-01 15:39:50 +00:00
step_validate_template_test.go make tests pass again 2018-05-01 15:39:50 +00:00
template_factory.go Add some error checking 2020-07-16 23:22:24 +00:00
template_factory_test.TestKeyVaultDeployment03.approved.json Add KeyVault parameter and fix whitespace 2020-03-11 21:13:10 -04:00
template_factory_test.TestPlanInfo01.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestPlanInfo02.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment03.approved.json Update tests for datadisk name change 2020-04-05 01:16:24 +05:30
template_factory_test.TestVirtualMachineDeployment04.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment05.approved.json Update tests for datadisk name change 2020-04-05 01:16:24 +05:30
template_factory_test.TestVirtualMachineDeployment06.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment07.approved.json Update tests for datadisk name change 2020-04-05 01:16:24 +05:30
template_factory_test.TestVirtualMachineDeployment08.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment09.approved.json Update tests for datadisk name change 2020-04-05 01:16:24 +05:30
template_factory_test.TestVirtualMachineDeployment10.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment11.approved.json Fix spacing and line endings 2020-06-24 09:20:32 -04:00
template_factory_test.TestVirtualMachineDeployment12.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.TestVirtualMachineDeployment13.approved.json Update tests for datadisk name change 2020-04-05 01:16:24 +05:30
template_factory_test.TestVirtualMachineDeployment14.approved.json Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
template_factory_test.go Disable password auth on ssh key Linux builds 2020-07-16 22:26:06 +00:00
tempname.go builder/azure-arm: Update runtime constants with a valid DataDiskName 2020-05-18 14:57:20 -04:00
tempname_test.go Fix failing test & format code 2020-04-17 00:17:39 +05:30