Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle not found response when deleting app in wal rollback #220

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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