Skip to content

Commit

Permalink
handle not found response when deleting app in wal rollback (#220)
Browse files Browse the repository at this point in the history
* handle not found response when deleting app in wal rollback

* changelog

* changelog
  • Loading branch information
fairclothjm authored Oct 14, 2024
1 parent 9f81301 commit b8b9497
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Unreleased

## v0.20.1
### October 14, 2024

IMPROVEMENTS:

* Prevent noisy logs for non-existent or deleted out-of-band errors (https://github.com/hashicorp/vault-plugin-secrets-azure/pull/220)

## v0.20.0
IMPROVEMENTS:
* Bump Go version to 1.22.6
Expand Down
11 changes: 10 additions & 1 deletion wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ package azuresecrets

import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/vault/sdk/logical"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -69,7 +72,13 @@ func (b *azureSecretBackend) rollbackAppWAL(ctx context.Context, req *logical.Re
// maxWALAge (e.g. client creds have changed and the delete will never succeed),
// unconditionally remove the WAL.
if err := client.deleteApp(ctx, entry.AppObjID, true); err != nil {
b.Logger().Warn("rollback error deleting App", "err", err)
// Prevent noisy logs for non-existent or deleted out-of-band errors
respErr := new(azcore.ResponseError)
if errors.As(err, &respErr) && (respErr.StatusCode == http.StatusNoContent || respErr.StatusCode == http.StatusNotFound) {
b.Logger().Trace("app already deleted or does not exist", "err", err.Error())
} else {
b.Logger().Warn("rollback error deleting App", "err", err)
}

if time.Now().After(entry.Expiration) {
b.Logger().Warn("app WAL expired prior to rollback; resources may still exist")
Expand Down

0 comments on commit b8b9497

Please sign in to comment.