hashicorp / go-azure-sdk

An opinionated Go SDK for Azure Resource Manager
Mozilla Public License 2.0
34 stars 44 forks source link

DataProtection / API Version 2023-05-01 deletedbackupinstances.UndeleteThenPoll fails with 404 after the item gets undeleted #886

Open mbfrahry opened 8 months ago

mbfrahry commented 8 months ago

Is there an existing issue for this?

Community Note

Service Used

Data Protection

API Versions Used

2023-05-01

Description

I am running UndeleteThenPoll and it looks like the command errors with 404 after the specified item is undeleted.

I believe that 404 should actually be our success trigger for when the Undelete finishes as the item no longer exists in that deletedbackupinstances api and should now show up in the backupinstances api.

References

No response

tombuildsstuff commented 7 months ago

Presumably this is a duplicate of https://github.com/hashicorp/go-azure-sdk/issues/740?

mbfrahry commented 7 months ago

I don't believe so. The issue you linked is on first poll. This one is when the operation succeeds. UnDelete seems to just be a Delete

tombuildsstuff commented 7 months ago

@mbfrahry if you've got them handy, mind posting the Request/Responses?

mbfrahry commented 7 months ago

Here is the Request

:authority: management.azure.com
:method: POST
:path: /subscriptions/XXXX-XXXX-XXXX/resourceGroups/acctest-dataprotection-240220010123990118/providers/Microsoft.DataProtection/backupVaults/acctest-dataprotection-vault-240220010123990118/deletedBackupInstances/acctest-dbi-240220010123990118/undelete?api-version=2023-05-01
:scheme: https
authorization: bearer-token
content-type: application/json; charset=utf-8
user-agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 deletedbackupinstances/2023-05-01)
content-length: 0
accept-encoding: gzip

And the response

:status: 200
cache-control: no-cache
pragma: no-cache
expires: -1
x-content-type-options: nosniff
x-ms-ratelimit-remaining-subscription-resource-requests: 1999
x-ms-request-id: e0286909-e544-4035-aa8e-95df30c6bc1d
x-ms-correlation-request-id: e0286909-e544-4035-aa8e-95df30c6bc1d
x-ms-routing-request-id: WESTUS2:20240220T190455Z:e0286909-e544-4035-aa8e-95df30c6bc1d
strict-transport-security: max-age=31536000; includeSubDomains
x-cache: CONFIG_NOCACHE
x-msedge-ref: Ref A: A873213E615F497B95221F26EED32CDF Ref B: CO6AA3150220029 Ref C: 2024-02-20T19:04:53Z
date: Tue, 20 Feb 2024 19:04:54 GMT
content-length: 0

And then we do a Get:

:authority: management.azure.com
:method: GET
:path: /subscriptions/XXXX-XXX-XXX/resourceGroups/acctest-dataprotection-240220010123990118/providers/Microsoft.DataProtection/backupVaults/acctest-dataprotection-vault-240220010123990118/deletedBackupInstances/acctest-dbi-240220010123990118?api-version=2023-05-01
:scheme: https
content-type: application/json; charset=utf-8
user-agent: HashiCorp/go-azure-sdk (Go-http-Client/1.1 deletedbackupinstances/2023-05-01)
accept: application/json; charset=utf-8; IEEE754Compatible=false
odata-maxversion: 4.0
odata-version: 4.0
authorization: bearer-token
accept-encoding: gzip

And that returns

:status: 404
cache-control: no-cache
pragma: no-cache
content-length: 218
content-type: application/json
content-language: en-US
expires: -1
x-ms-ratelimit-remaining-subscription-resource-requests: 1999
x-content-type-options: nosniff
x-ms-error-code: UserErrorGenericResourceNotFound
x-ms-request-id: 7a01ad74-47c9-4b5b-86af-b8140191e190
x-ms-correlation-request-id: 7a01ad74-47c9-4b5b-86af-b8140191e190
x-ms-routing-request-id: WESTUS:20240220T190506Z:7a01ad74-47c9-4b5b-86af-b8140191e190
strict-transport-security: max-age=31536000; includeSubDomains
x-cache: CONFIG_NOCACHE
x-msedge-ref: Ref A: B3EBB63BD7BE414E8490D3C5E3A7EBD7 Ref B: CO6AA3150218011 Ref C: 2024-02-20T19:05:05Z
date: Tue, 20 Feb 2024 19:05:05 GMT

{"error":{"code":"UserErrorGenericResourceNotFound","message":"Azure resource does not exist. Please make sure required resources exist. If the issue persists, contact Microsoft support.","target":null,"details":null}}

So I guess that does make it like the other issue 🤔 except we aren't waiting for it to be created as subsequent Get calls will always return resource not found since it's moved from deletedbackupinstances to backupinstances

mbfrahry commented 7 months ago

tl;dr 404 should be treated as success for UndeleteThenPoll

tombuildsstuff commented 7 months ago

Ah fun, so it appears to be a Delete LRO masquerading as Regular LRO? We'll likely need to update the Regular vs Delete LRO logic to check if the URI contains delete to handle this, I suspect.