Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensors: modify unload hooks and remove GetConfig and SetConfig #1385

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Aug 24, 2023

See individual commits, the last one removes a deprecated and unused thing in sensors.

These patches were made in order for us (me) to be able to use PostUnloadHook later on.

UnloadHook is called before the programs and maps are being removed. In
preparation to the addition of a PostUnloadHook, we rename the hook to
PreUnloadHook to be more explicit.

Signed-off-by: Mahe Tardy <[email protected]>
This hook is a complement to PreUnloadHook freshly renamed in previous
commit. It is intended to replace Ops.Unloaded to be called at the
sensor level and not the collection level.

Signed-off-by: Mahe Tardy <[email protected]>
This operation was replaced with previous commit's PostUnloadHook and is
now directly called from *Sensor.Unload instead of collection caller.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy requested a review from a team as a code owner August 24, 2023 14:01
@mtardy mtardy requested a review from tixxdz August 24, 2023 14:01
@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 06fef18
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/64e762ccb42dc900083a927d
😎 Deploy Preview https://deploy-preview-1385--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mtardy mtardy requested review from kkourt and kevsecurity and removed request for tixxdz August 24, 2023 14:02
This removes the Ops Operations field on the Sensor struct since it's no
longer needed. It removes the Loaded hook that was called at a
collection of sensor loading time. We can add LoadHook (similarly as Pre
and Post UnloadHook) in the future if it's needed again. It removes
GetConfig and SetConfig along and removes those functions from the API
since they were already not used, see this note:

> NB: sensorConfigSet was used before tracing policies were
> introduced. The idea was that it could be used to provide
> sensor-specifc configuration values. We can either modify the
> call to specify a sensor within a collection, or completely
> remove it. TBD.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy force-pushed the pr/mtardy/cleanup-generic-sensor branch from 06fef18 to 321be09 Compare August 24, 2023 14:13
Previously, we kept all the unloaded kprobe entries in the generic
kprobe table forever, never calling RemoveEntry. This patch uses
PostUnloadHook to cleanup the entry from the table at unload time, other
cleanups could be performed there if needed.

Signed-off-by: Mahe Tardy <[email protected]>
pkg/sensors/load.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but it would be great if you could add a test to ensure that removing the entries works as expected.

@mtardy
Copy link
Member Author

mtardy commented Aug 24, 2023

LGTM, but it would be great if you could add a test to ensure that removing the entries works as expected.

Thanks will add a test in this PR!

@mtardy mtardy force-pushed the pr/mtardy/cleanup-generic-sensor branch from df0e1ce to 2b74b4b Compare August 24, 2023 18:02
@mtardy mtardy merged commit d69b94d into main Aug 25, 2023
28 checks passed
@mtardy mtardy deleted the pr/mtardy/cleanup-generic-sensor branch August 25, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants