From 79982d3b404907617f22c20f27b667e381ec5557 Mon Sep 17 00:00:00 2001 From: jm96441n Date: Wed, 17 Apr 2024 19:22:01 +0000 Subject: [PATCH 1/2] backport of commit 09cc0338be0ff203d46fa8ec163010b495c45b78 --- control-plane/api-gateway/cache/consul.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/control-plane/api-gateway/cache/consul.go b/control-plane/api-gateway/cache/consul.go index 6ae055384a..7ffbd25f34 100644 --- a/control-plane/api-gateway/cache/consul.go +++ b/control-plane/api-gateway/cache/consul.go @@ -359,6 +359,9 @@ func (c *Cache) ensurePolicy(client *api.Client, gatewayName string) (string, er if err != nil { return "", err } + + // on an upgrade the cache will be empty so we need to write the policy to the cache + c.gatewayNameToPolicy[gatewayName] = existing return existing.ID, nil } @@ -386,6 +389,8 @@ func (c *Cache) ensurePolicy(client *api.Client, gatewayName string) (string, er return "", err } + // update cache with existing policy + c.gatewayNameToPolicy[gatewayName] = existing return existing.ID, nil } @@ -426,7 +431,8 @@ func (c *Cache) ensureRole(client *api.Client, gatewayName string) (string, erro } if aclRole != nil { - return cachedRole.Name, nil + c.gatewayNameToRole[gatewayName] = aclRole + return aclRole.Name, nil } return createRole() From 6862f2bd169e16984568a6390dbb1c87d487c78a Mon Sep 17 00:00:00 2001 From: jm96441n Date: Thu, 18 Apr 2024 15:28:16 -0400 Subject: [PATCH 2/2] Added changelog --- .changelog/3918.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3918.txt diff --git a/.changelog/3918.txt b/.changelog/3918.txt new file mode 100644 index 0000000000..dad22ff2db --- /dev/null +++ b/.changelog/3918.txt @@ -0,0 +1,3 @@ +```release-note:bug +api-gateway: Fix order of initialization for creating ACL role/policy to avoid error logs in consul when upgrading between versions. +```