Skip to content

Commit

Permalink
tetragon: Add keep-sensors-on-exit option
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Jun 29, 2024
1 parent fcfc616 commit e79f9da
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/tetragon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ func tetragonExecute() error {
log.Info("Force loading smallprograms")
}

if option.Config.KeepSensorsOnExit {
log.Info("Not unloading sensors on exit")
}

if viper.IsSet(option.KeyNetnsDir) {
defaults.NetnsDir = viper.GetString(option.KeyNetnsDir)
}
Expand Down
3 changes: 3 additions & 0 deletions docs/data/tetragon_flags.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/option/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ type config struct {

HealthServerAddress string
HealthServerInterval int

KeepSensorsOnExit bool
}

var (
Expand Down
6 changes: 6 additions & 0 deletions pkg/option/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ const (
KeyHealthTimeInterval = "health-server-interval"

KeyBpfDir = "bpf-dir"

KeyKeepSensorsOnExit = "keep-sensors-on-exit"
)

type UsernameMetadaCode int
Expand Down Expand Up @@ -222,6 +224,8 @@ func ReadAndSetFlags() error {
Config.HealthServerInterval = viper.GetInt(KeyHealthTimeInterval)

Config.BpfDir = viper.GetString(KeyBpfDir)

Config.KeepSensorsOnExit = viper.GetBool(KeyKeepSensorsOnExit)
return nil
}

Expand Down Expand Up @@ -378,4 +382,6 @@ func AddFlags(flags *pflag.FlagSet) {
flags.Int(KeyHealthTimeInterval, 10, "Health server interval in seconds")

flags.String(KeyBpfDir, defaults.DefaultMapPrefix, "Set tetragon bpf directory (default 'tetragon')")

flags.Bool(KeyKeepSensorsOnExit, false, "Do not unload sensors on exit")
}
2 changes: 1 addition & 1 deletion pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func linkPinPath(bpfDir string, load *Program, extra ...string) string {

func linkPin(lnk link.Link, bpfDir string, load *Program, extra ...string) error {
// pinned link is not configured
if !load.PinLink {
if !option.Config.KeepSensorsOnExit && !load.PinLink {
return nil
}
// pinned link is not supported
Expand Down

0 comments on commit e79f9da

Please sign in to comment.