Skip to content

Commit

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

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
  • Loading branch information
kkourt committed Jun 10, 2024
1 parent acefdba commit 2d97c70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sensors/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
LoadErrorState
ErrorState
LoadingState
UnloadingState
)

func (s TracingPolicyState) ToTetragonState() tetragon.TracingPolicyState {
Expand All @@ -35,6 +36,8 @@ func (s TracingPolicyState) ToTetragonState() tetragon.TracingPolicyState {
return tetragon.TracingPolicyState_TP_STATE_ERROR
case LoadingState:
return tetragon.TracingPolicyState_TP_STATE_LOADING
case UnloadingState:
return tetragon.TracingPolicyState_TP_STATE_UNLOADING
default:
return tetragon.TracingPolicyState_TP_STATE_UNKNOWN
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/sensors/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ func (h *handler) disableTracingPolicy(op *tracingPolicyDisable) error {
return fmt.Errorf("tracing policy %s is not enabled", op.ck)
}

col.state = UnloadingState
// unlock so that policyLister can access the collections (read-only) while we are unloading.
h.collections.mu.Unlock()
err := col.unload()
h.collections.mu.Lock()

if err != nil {
// for now, the only way col.unload() can return an error is if the
// collection is not currently loaded, which should be impossible
Expand Down

0 comments on commit 2d97c70

Please sign in to comment.