Skip to content

Commit

Permalink
fix: Resolve errors for resource not found (#633)
Browse files Browse the repository at this point in the history
Co-authored-by: yl5722 <[email protected]>
Co-authored-by: Alex Leites <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent 906111f commit a4c40b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/providers/instance/armutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func deleteNicIfExists(ctx context.Context, client NetworkInterfacesAPI, rg, nic
func deleteVirtualMachineIfExists(ctx context.Context, client VirtualMachinesAPI, rg, vmName string) error {
_, err := client.Get(ctx, rg, vmName, nil)
if err != nil {
if sdkerrors.IsNotFoundErr(err) {
azErr := sdkerrors.IsResponseError(err)
if azErr != nil && (azErr.ErrorCode == "NotFound" || azErr.ErrorCode == "ResourceNotFound") {
return nil
}
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func (p *DefaultProvider) Get(ctx context.Context, vmName string) (*armcompute.V
var err error

if vm, err = p.azClient.virtualMachinesClient.Get(ctx, p.resourceGroup, vmName, nil); err != nil {
if sdkerrors.IsNotFoundErr(err) {
azErr := sdkerrors.IsResponseError(err)
if azErr != nil && (azErr.ErrorCode == "NotFound" || azErr.ErrorCode == "ResourceNotFound") {
return nil, corecloudprovider.NewNodeClaimNotFoundError(err)
}
return nil, fmt.Errorf("failed to get VM instance, %w", err)
Expand Down

0 comments on commit a4c40b0

Please sign in to comment.