Skip to content

Commit

Permalink
platform/api/azure: Don't wait for rg/vm deletion
Browse files Browse the repository at this point in the history
Waiting for deletion slows down overall test execution and we have automation
that regularly cleans up orpaphaned resources.

Signed-off-by: Jeremi Piotrowski <[email protected]>
  • Loading branch information
jepio committed Jul 3, 2024
1 parent d4ae722 commit 093b028
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
7 changes: 1 addition & 6 deletions platform/api/azure/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down
13 changes: 4 additions & 9 deletions platform/api/azure/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 093b028

Please sign in to comment.