Skip to content

Commit

Permalink
sensors: allow listing policies while enabling
Browse files Browse the repository at this point in the history
This patch modifies disableTracingPolicy to release the lock to the
collections while enabling a sensor. Before releasing the lock, the state
is changed to LoadingState.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
  • Loading branch information
kkourt committed Jun 10, 2024
1 parent 2d97c70 commit 30ebb6c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/sensors/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,15 @@ func (h *handler) enableTracingPolicy(op *tracingPolicyEnable) error {
return fmt.Errorf("tracing policy %s is not disabled", op.ck)
}

if err := col.load(h.bpfDir); err != nil {
col.state = LoadingState
// unlock so that policyLister can access the collections (read-only) while we are loading.
h.collections.mu.Unlock()
err := col.load(h.bpfDir)
h.collections.mu.Lock()

if err != nil {
col.state = LoadErrorState
col.err = fmt.Errorf("failed to load tracing policy %q: %w", col.name, err)
col.err = fmt.Errorf("failed to enable tracing policy %q: %w", col.name, err)
return col.err
}

Expand Down

0 comments on commit 30ebb6c

Please sign in to comment.