From 58dcbf01a635d4b605112d67ffcb7d4ca3c9b8c0 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Fri, 7 Jul 2023 15:22:34 -0500 Subject: [PATCH] backport of commit 2dced0a8b95b7d536751e22c028ae61bf1b9fb62 (#17848) This pull request was automerged via backport-assistant --- .changelog/17847.txt | 3 +++ nomad/consul.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changelog/17847.txt diff --git a/.changelog/17847.txt b/.changelog/17847.txt new file mode 100644 index 000000000000..7bbee3d3f393 --- /dev/null +++ b/.changelog/17847.txt @@ -0,0 +1,3 @@ +```release-note:bug +consul: Fixed a bug where Nomad would repeatedly try to revoke successfully revoked SI tokens +``` diff --git a/nomad/consul.go b/nomad/consul.go index e5fe3fe73085..8be4dfd9a2f1 100644 --- a/nomad/consul.go +++ b/nomad/consul.go @@ -427,8 +427,10 @@ func (c *consulACLsAPI) singleRevoke(ctx context.Context, accessor *structs.SITo return err } - // Consul will no-op the deletion of a non-existent token (no error) _, err := c.aclClient.TokenDelete(accessor.AccessorID, &api.WriteOptions{Namespace: accessor.ConsulNamespace}) + if err != nil && strings.Contains(err.Error(), "Cannot find token to delete") { + return nil // Consul will error when deleting a non-existent token + } return err }