From 5fbae441e56b61627ab9703d49bf12edb645ac8d Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Mon, 9 Sep 2024 12:29:24 -0500 Subject: [PATCH 1/3] handle not found response when deleting app in wal rollback --- wal.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wal.go b/wal.go index bbc6a3c4..2b57b2b7 100644 --- a/wal.go +++ b/wal.go @@ -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" @@ -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") From 0e5841589bbd5b49112cdd1b109db48309e06f92 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Mon, 14 Oct 2024 10:54:51 -0500 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb07f0a..248ebc33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased +* 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 From 8bafd88493fb7a769bf20f7ad919eb42e36878bb Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Mon, 14 Oct 2024 11:00:51 -0500 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 248ebc33..9636a6ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 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