Skip to content

Commit

Permalink
egressgw: avoid multiple updatePoliciesBySourceIP calls
Browse files Browse the repository at this point in the history
after the switch to the trigger based reconciliation, the reconciliation
can handle multiple type of events in one batch.

Update the logic so that we don't end up calling
updatePoliciesBySourceIP() twice in case we are processing a batch for
both endpoint and policy events.

Co-authored-by: André Martins <andre@cilium.io>
Signed-off-by: Gilberto Bertin <jibi@cilium.io>
  • Loading branch information
jibi and aanm committed Jul 19, 2023
1 parent ccba1a1 commit 5ed7160
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pkg/egressgateway/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,20 +842,14 @@ func (manager *Manager) reconcileLocked() {
return
}

if manager.eventBitmapIsSet(eventUpdateEndpoint, eventDeleteEndpoint) {
manager.updatePoliciesMatchedEndpointIDs()
manager.updatePoliciesBySourceIP()
}

if manager.eventBitmapIsSet(eventAddPolicy, eventDeletePolicy) {
manager.updatePoliciesBySourceIP()
}

switch {
// on eventK8sSyncDone we need to update all caches unconditionally as
// we don't know which k8s events/resources were received during the
// initial k8s sync
if manager.eventBitmapIsSet(eventK8sSyncDone) {
case manager.eventBitmapIsSet(eventUpdateEndpoint, eventDeleteEndpoint, eventK8sSyncDone):
manager.updatePoliciesMatchedEndpointIDs()
fallthrough
case manager.eventBitmapIsSet(eventAddPolicy, eventDeletePolicy):
manager.updatePoliciesBySourceIP()
}

Expand Down

0 comments on commit 5ed7160

Please sign in to comment.