Skip to content

Commit

Permalink
tetragon: Plug in the config object
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Mar 7, 2024
1 parent 25f365e commit c0e406f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/tetragon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cilium/tetragon/pkg/bugtool"
"github.com/cilium/tetragon/pkg/checkprocfs"
"github.com/cilium/tetragon/pkg/cilium"
"github.com/cilium/tetragon/pkg/config"
"github.com/cilium/tetragon/pkg/defaults"
"github.com/cilium/tetragon/pkg/encoder"
"github.com/cilium/tetragon/pkg/exporter"
Expand Down Expand Up @@ -436,6 +437,13 @@ func tetragonExecute() error {
base.Unload()
}()

onReconfig := func(data *config.Data) {
option.Config.DisableKprobeMulti = data.DisableKprobeMulti
}

cfg := config.NewConfig(option.Config.ConfigFile, 5*time.Second, onReconfig)
defer cfg.Stop()

// now that the base sensor was loaded, we can start the sensor manager
close(sensorMgWait)
sensorMgWait = nil
Expand Down
2 changes: 2 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 @@ -86,6 +86,8 @@ type config struct {
EnableTracingPolicyCRD bool

ExposeKernelAddresses bool

ConfigFile string
}

var (
Expand Down
5 changes: 5 additions & 0 deletions pkg/option/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const (
KeyExposeKernelAddresses = "expose-kernel-addresses"

KeyGenerateDocs = "generate-docs"

KeyConfigFile = "config-file"
)

func ReadAndSetFlags() error {
Expand Down Expand Up @@ -172,6 +174,7 @@ func ReadAndSetFlags() error {

Config.ExposeKernelAddresses = viper.GetBool(KeyExposeKernelAddresses)

Config.ConfigFile = viper.GetString(KeyConfigFile)
return nil
}

Expand Down Expand Up @@ -278,4 +281,6 @@ func AddFlags(flags *pflag.FlagSet) {
flags.Bool(KeyExposeKernelAddresses, false, "Expose real kernel addresses in events stack traces")

flags.Bool(KeyGenerateDocs, false, "Generate documentation in YAML format to stdout")

flags.String(KeyConfigFile, "", "configuration file")
}

0 comments on commit c0e406f

Please sign in to comment.