Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of [NET-8412] Fix APIGW policy creation ordering for upgrade path into release/1.2.x #3925

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
}

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

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