Skip to content

Commit

Permalink
[NET-8412] Fix APIGW policy creation ordering for upgrade path (#3918)
Browse files Browse the repository at this point in the history
* fix policy creation for upgrading

* Added changelog
  • Loading branch information
jm96441n authored Apr 19, 2024
1 parent a8280cf commit 6dfbadf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/3918.txt
Original file line number Diff line number Diff line change
@@ -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.
```
8 changes: 7 additions & 1 deletion control-plane/api-gateway/cache/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6dfbadf

Please sign in to comment.