From 44b9ab77503ffb4cc5618dbdedd6b2cb302224e9 Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Mon, 9 Sep 2024 12:29:24 -0500 Subject: [PATCH] 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")