Skip to content

Commit

Permalink
tetragon: Do not rename old sysfs directory for --release-pinned-bpf …
Browse files Browse the repository at this point in the history
…option

If there's --release-pinned-bpf option enabled, we need to remove
previous sysfs instance right away, so don't bother renaming that.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri authored and jrfastab committed Aug 13, 2024
1 parent 9efa574 commit 64d620e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/tetragon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ func stopProfile() {
}

func getOldBpfDir(path string) (string, error) {
// sysfs directory will be removed, so we don't care
if option.Config.ReleasePinned {
return "", nil
}
if _, err := os.Stat(path); err != nil {
return "", nil
}
Expand Down Expand Up @@ -279,6 +283,13 @@ func tetragonExecute() error {
bpf.CheckOrMountCgroup2()
bpf.SetMapPrefix(option.Config.BpfDir)

// We try to detect previous instance, which might be there for legitimate reasons
// (--keep-sensors-on-exit) and rename to 'tetragon_old'.
// Then we do the 'best' effort to keep running sensors as long as possible and remove
// 'tetragon_old' directory when tetragon is started and its policy is loaded.
// If there's --release-pinned-bpf option enabled, we need to remove previous sysfs
// instance right away (see check for option.Config.ReleasePinned below), so we don't
// bother renaming in that case.
oldBpfDir, err := getOldBpfDir(bpf.MapPrefixPath())
if err != nil {
return fmt.Errorf("Failed to move old tetragon base directory: %w", err)
Expand Down

0 comments on commit 64d620e

Please sign in to comment.