Skip to content

Commit

Permalink
sensors: allow listing policies after removal
Browse files Browse the repository at this point in the history
Instead of destroying the sensors of a policy and then removing them
from the collection, remove them first and then destroy them. Once we
remove them, we can release the collection lock that allows listing of
the policies.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
  • Loading branch information
kkourt committed Jun 10, 2024
1 parent f8111e5 commit acefdba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/sensors/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ func (h *handler) addTracingPolicy(op *tracingPolicyAdd) error {

func (h *handler) deleteTracingPolicy(op *tracingPolicyDelete) error {
h.collections.mu.Lock()
defer h.collections.mu.Unlock()
collections := h.collections.c
col, exists := collections[op.ck]
if !exists {
h.collections.mu.Unlock()
return fmt.Errorf("tracing policy %s does not exist", op.ck)
}
defer delete(collections, op.ck)
delete(collections, op.ck)
// we have removed the collection, so unlock the map so that the lister can quickly view
// that the collection is gone
h.collections.mu.Unlock()

col.destroy()

Expand Down

0 comments on commit acefdba

Please sign in to comment.