From aaa6f51841993544b0e0f36acc270f388159bddc Mon Sep 17 00:00:00 2001 From: jm96441n Date: Wed, 17 Apr 2024 19:22:01 +0000 Subject: [PATCH] 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 0b0d067df7..984f6db7b4 100644 --- a/control-plane/api-gateway/cache/consul.go +++ b/control-plane/api-gateway/cache/consul.go @@ -362,6 +362,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 } @@ -389,6 +392,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 } @@ -429,7 +434,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()