Skip to content

Commit

Permalink
l2announcer: Fix delete entry if no origins left
Browse files Browse the repository at this point in the history
When enabling L2Announcer and using the sharedingkeys feature,
deleting a service that uses the same requestIP will unexpectedly
delete the allocated LB IP in the Cilium agent.

Fixes: cilium#32115

Signed-off-by: Taizeng Wu <wutaizeng@gmail.com>
  • Loading branch information
wutz committed May 1, 2024
1 parent 6fca78d commit d956407
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/l2announcer/l2announcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,15 @@ func (l2a *L2Announcer) recalculateL2EntriesTableEntries(ss *selectedService) er
e.Origins = slices.Delete(e.Origins, idx, idx+1)
}

_, _, err := tbl.Delete(txn, e)
if len(e.Origins) == 0 {
_, _, err := tbl.Delete(txn, e)
if err != nil {
return fmt.Errorf("delete in table: %w", err)
}
return nil
}

_, _, err := tbl.Insert(txn, e)
if err != nil {
return fmt.Errorf("update in table: %w", err)
}
Expand Down

0 comments on commit d956407

Please sign in to comment.