From 47107e635571fc982557efb1c46693e881f0b83d Mon Sep 17 00:00:00 2001 From: Paul Meyer Date: Tue, 31 Mar 2020 22:19:58 +0000 Subject: [PATCH] Default polling delay 5 sec --- builder/azure/chroot/step_create_new_disk.go | 5 ++++- builder/azure/chroot/step_create_snapshot.go | 5 ++++- builder/azure/common/client/azure_client_set.go | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/builder/azure/chroot/step_create_new_disk.go b/builder/azure/chroot/step_create_new_disk.go index d672dfd31..5ed688b67 100644 --- a/builder/azure/chroot/step_create_new_disk.go +++ b/builder/azure/chroot/step_create_new_disk.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "time" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" "github.com/Azure/go-autorest/autorest/azure" @@ -98,7 +99,9 @@ func (s *StepCreateNewDisk) Run(ctx context.Context, state multistep.StateBag) m f, err := azcli.DisksClient().CreateOrUpdate(ctx, s.resourceGroup, s.diskName, disk) if err == nil { - err = f.WaitForCompletionRef(ctx, azcli.PollClient()) + cli := azcli.PollClient() // quick polling for quick operations + cli.PollingDelay = time.Second + err = f.WaitForCompletionRef(ctx, cli) } if err != nil { log.Printf("StepCreateNewDisk.Run: error: %+v", err) diff --git a/builder/azure/chroot/step_create_snapshot.go b/builder/azure/chroot/step_create_snapshot.go index dad7275ca..61ff36e9c 100644 --- a/builder/azure/chroot/step_create_snapshot.go +++ b/builder/azure/chroot/step_create_snapshot.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "time" "github.com/hashicorp/packer/builder/azure/common/client" "github.com/hashicorp/packer/helper/multistep" @@ -72,7 +73,9 @@ func (s *StepCreateSnapshot) Run(ctx context.Context, state multistep.StateBag) f, err := azcli.SnapshotsClient().CreateOrUpdate(ctx, s.resourceGroup, s.snapshotName, snapshot) if err == nil { - err = f.WaitForCompletionRef(ctx, azcli.PollClient()) + cli := azcli.PollClient() // quick polling for quick operations + cli.PollingDelay = time.Second + err = f.WaitForCompletionRef(ctx, cli) } if err != nil { log.Printf("StepCreateSnapshot.Run: error: %+v", err) diff --git a/builder/azure/common/client/azure_client_set.go b/builder/azure/common/client/azure_client_set.go index c42bcee4b..4fac8e804 100644 --- a/builder/azure/common/client/azure_client_set.go +++ b/builder/azure/common/client/azure_client_set.go @@ -5,10 +5,11 @@ import ( "regexp" "time" + "github.com/hashicorp/packer/helper/useragent" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute/computeapi" "github.com/Azure/go-autorest/autorest" - "github.com/hashicorp/packer/helper/useragent" ) type AzureClientSet interface { @@ -127,6 +128,6 @@ func (s azureClientSet) GalleryImageVersionsClient() computeapi.GalleryImageVers func (s azureClientSet) PollClient() autorest.Client { c := autorest.NewClientWithUserAgent("Packer-Azure-ClientSet") s.configureAutorestClient(&c) - c.PollingDelay = time.Second / 3 + c.PollingDelay = time.Second * 5 return c }