From aa8250bcc8ff62d07331330f573a836b2299b7c6 Mon Sep 17 00:00:00 2001 From: Paul Meyer Date: Wed, 29 Apr 2020 22:11:16 +0000 Subject: [PATCH] give temp data disks lun suffix --- builder/azure/chroot/step_create_new_diskset.go | 5 +---- builder/azure/chroot/step_create_new_diskset_test.go | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/builder/azure/chroot/step_create_new_diskset.go b/builder/azure/chroot/step_create_new_diskset.go index dee45ea1b..3d188b2a5 100644 --- a/builder/azure/chroot/step_create_new_diskset.go +++ b/builder/azure/chroot/step_create_new_diskset.go @@ -84,8 +84,6 @@ func (s *StepCreateNewDiskset) Run(ctx context.Context, state multistep.StateBag futures := []Future{{osDisk, f}} if s.SourceImageResourceID != "" { - datadiskSuffix := 0 // initialize - // retrieve image to see if there are any datadisks imageID, err := client.ParseResourceID(s.SourceImageResourceID) if err != nil { @@ -108,8 +106,7 @@ func (s *StepCreateNewDiskset) Run(ctx context.Context, state multistep.StateBag if ddi.Lun == nil { return errorMessage("unexpected: lun is null for data disk # %d", i) } - datadiskID, err := client.ParseResourceID(fmt.Sprintf("%s%d", s.DataDiskIDPrefix, datadiskSuffix)) - datadiskSuffix++ + datadiskID, err := client.ParseResourceID(fmt.Sprintf("%s%d", s.DataDiskIDPrefix, *ddi.Lun)) if err != nil { return errorMessage("unable to construct resource id for datadisk: %v", err) } diff --git a/builder/azure/chroot/step_create_new_diskset_test.go b/builder/azure/chroot/step_create_new_diskset_test.go index aa06d69d7..d85dc34d8 100644 --- a/builder/azure/chroot/step_create_new_diskset_test.go +++ b/builder/azure/chroot/step_create_new_diskset_test.go @@ -165,9 +165,9 @@ func TestStepCreateNewDisk_Run(t *testing.T) { want: multistep.ActionContinue, verifyDiskset: &Diskset{ -1: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryOSDiskName"), - 3: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-2"), - 5: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-0"), - 9: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-1"), + 3: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-3"), + 5: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-5"), + 9: resource("/subscriptions/SubscriptionID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/disks/TemporaryDataDisk-9"), }, }, }