Skip to content

Commit

Permalink
tetragon: Remove StopSensorManager function
Browse files Browse the repository at this point in the history
We removed the go routine, so it's no longer needed.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Oct 31, 2024
1 parent f520d68 commit 34816e6
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 67 deletions.
1 change: 0 additions & 1 deletion pkg/observer/observertesthelper/observer_test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ func loadExporter(tb testing.TB, ctx context.Context, obs *observer.Observer, op
// this up and remove/hide the global variable.
sensorManager := observer.GetSensorManager()
tb.Cleanup(func() {
sensorManager.StopSensorManager(ctx)
observer.ResetSensorManager()
})

Expand Down
4 changes: 0 additions & 4 deletions pkg/sensors/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ func (h *Manager) RemoveAllSensors(ctx context.Context) error {
return h.handler.removeSensor(op)
}

func (h *Manager) StopSensorManager(ctx context.Context) error {
return nil
}

func (h *Manager) LogSensorsAndProbes(ctx context.Context) {
log := logger.GetLogger()
sensors, err := h.ListSensors(ctx)
Expand Down
46 changes: 0 additions & 46 deletions pkg/sensors/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ func TestAddPolicy(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
assert.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
err = mgr.AddTracingPolicy(ctx, &policy)
assert.NoError(t, err)
Expand All @@ -73,11 +68,6 @@ func TestAddPolicies(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
assert.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
err = mgr.AddTracingPolicy(ctx, &policy)
assert.NoError(t, err)
Expand All @@ -104,11 +94,6 @@ func TestAddPolicySpecError(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
assert.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
err = mgr.AddTracingPolicy(ctx, &policy)
assert.NotNil(t, err)
Expand Down Expand Up @@ -136,11 +121,6 @@ func TestAddPolicyLoadError(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
assert.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
addError := mgr.AddTracingPolicy(ctx, &policy)
assert.NotNil(t, addError)
Expand All @@ -159,7 +139,6 @@ func TestPolicyFilterDisabled(t *testing.T) {

mgr, err := StartSensorManagerWithPF("", policyfilter.DisabledState())
assert.NoError(t, err)
defer mgr.StopSensorManager(ctx)

policy := v1alpha1.TracingPolicy{}

Expand Down Expand Up @@ -211,11 +190,6 @@ func TestPolicyStates(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
addError := mgr.AddTracingPolicy(ctx, &policy)
assert.NotNil(t, addError)
Expand All @@ -236,11 +210,6 @@ func TestPolicyStates(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
err = mgr.AddTracingPolicy(ctx, &policy)
assert.NoError(t, err)
Expand Down Expand Up @@ -276,11 +245,6 @@ func TestPolicyLoadErrorOverride(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
addError := mgr.AddTracingPolicy(ctx, &policy)
assert.NotNil(t, addError)
Expand Down Expand Up @@ -315,11 +279,6 @@ func TestPolicyListingWhileLoadUnload(t *testing.T) {

mgr, err := StartSensorManager("")
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})

checkPolicy := func(t *testing.T, statuses []*tetragon.TracingPolicyStatus, state tetragon.TracingPolicyState) {
require.Equal(t, 1, len(statuses))
Expand Down Expand Up @@ -442,11 +401,6 @@ func TestPolicyKernelMemoryBytes(t *testing.T) {
policy := v1alpha1.TracingPolicy{}
mgr, err := StartSensorManager("")
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})
policy.ObjectMeta.Name = "test-policy"
addError := mgr.AddTracingPolicy(ctx, &policy)
// this will fail to load because the programs do not exist
Expand Down
10 changes: 0 additions & 10 deletions pkg/sensors/tracing/generickprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ func Test_DisableEnablePolicy_Kprobe(t *testing.T) {
path := bpf.MapPrefixPath()
mgr, err := sensors.StartSensorManager(path)
assert.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})

t.Run("sensor", func(t *testing.T) {
err = mgr.AddTracingPolicy(ctx, &tcpConnectPolicy)
Expand Down Expand Up @@ -192,11 +187,6 @@ func Test_DisableEnablePolicy_KernelMemoryBytes(t *testing.T) {
path := bpf.MapPrefixPath()
mgr, err := sensors.StartSensorManager(path)
require.NoError(t, err)
t.Cleanup(func() {
if err := mgr.StopSensorManager(ctx); err != nil {
t.Fatal("failed to stop sensor manager")
}
})

err = mgr.AddTracingPolicy(ctx, &tcpConnectPolicy)
require.NoError(t, err)
Expand Down
6 changes: 0 additions & 6 deletions pkg/testutils/sensors/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ func getTestSensorManager(ctx context.Context, t *testing.T, pfState policyfilte
if err != nil {
t.Fatalf("StartSensorManagerWithPF failed: %s", err)
}
t.Cleanup(func() {
err := mgr.StopSensorManager(ctx)
if err != nil {
t.Logf("StopSensorManager failed: %s\n", err)
}
})

return &TestSensorManager{
Manager: mgr,
Expand Down

0 comments on commit 34816e6

Please sign in to comment.