From 093b028e33eae92b7af0c7546f8af98ce25e2391 Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Tue, 2 Jul 2024 08:43:35 +0200 Subject: [PATCH] platform/api/azure: Don't wait for rg/vm deletion Waiting for deletion slows down overall test execution and we have automation that regularly cleans up orpaphaned resources. Signed-off-by: Jeremi Piotrowski --- platform/api/azure/groups.go | 7 +------ platform/api/azure/instance.go | 13 ++++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/platform/api/azure/groups.go b/platform/api/azure/groups.go index 483e6206f..53228d7c5 100644 --- a/platform/api/azure/groups.go +++ b/platform/api/azure/groups.go @@ -18,7 +18,6 @@ import ( "context" "time" - azruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" ) @@ -58,11 +57,7 @@ func (a *API) TerminateResourceGroup(name string) error { opts := &armresources.ResourceGroupsClientBeginDeleteOptions{ ForceDeletionTypes: to.Ptr("Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"), } - poller, err := a.rgClient.BeginDelete(context.TODO(), name, opts) - pollOpts := &azruntime.PollUntilDoneOptions{ - Frequency: 15 * time.Second, - } - _, err = poller.PollUntilDone(context.TODO(), pollOpts) + _, err := a.rgClient.BeginDelete(context.TODO(), name, opts) return err } diff --git a/platform/api/azure/instance.go b/platform/api/azure/instance.go index b0fb69eb5..521457d32 100644 --- a/platform/api/azure/instance.go +++ b/platform/api/azure/instance.go @@ -275,17 +275,12 @@ func (a *API) CreateInstance(name, userdata, sshkey, resourceGroup, storageAccou // OS disk are deleted automatically together with the VM. func (a *API) TerminateInstance(machine *Machine, resourceGroup string) error { resourceGroup = a.getVMRG(resourceGroup) - poller, err := a.compClient.BeginDelete(context.TODO(), resourceGroup, machine.ID, &armcompute.VirtualMachinesClientBeginDeleteOptions{ + _, err := a.compClient.BeginDelete(context.TODO(), resourceGroup, machine.ID, &armcompute.VirtualMachinesClientBeginDeleteOptions{ ForceDeletion: to.Ptr(true), }) - if err != nil { - return err - } - _, err = poller.PollUntilDone(context.TODO(), nil) - if err != nil { - return err - } - return nil + // We used to wait for the VM to be deleted here, but it's not necessary as + // we will also delete the resource group later. + return err } func (a *API) GetConsoleOutput(name, resourceGroup, storageAccount string) ([]byte, error) {