Skip to content

Commit e733a99

Browse files
tixxdzjrfastab
authored andcommitted
tetragon:conf: store loglevel and cgroupFsMagic into BPF conf
Pass more runtime variables to TetragonConf struct that is stored inside `tg_conf_map` BPF map. These vars will be used by cgroup BPF programs. - NSPID: pid in current pid namespace from userspace point of view. - LogLevel: current user space loglevel - Cgroup FS Magic: either cgroupv1 or v2 Signed-off-by: Djalal Harouni <[email protected]>
1 parent f27fb16 commit e733a99

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/logger/log.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func ResetLogOutput() {
9696
DefaultLogger.SetOutput(os.Stdout)
9797
}
9898

99+
func GetLogLevel() logrus.Level {
100+
return DefaultLogger.GetLevel()
101+
}
102+
99103
func setLogLevel(logLevel logrus.Level) {
100104
DefaultLogger.SetLevel(logLevel)
101105
}

pkg/sensors/config/confmap/confmap.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ func UpdateTgRuntimeConf(mapDir string, nspid int) error {
105105

106106
k := &TetragonConfKey{Key: 0}
107107
v := &TetragonConfValue{
108+
LogLevel: uint32(logger.GetLogLevel()),
108109
TgCgrpHierarchy: cgroups.GetCgrpHierarchyID(),
109110
TgCgrpSubsysIdx: cgroups.GetCgrpSubsystemIdx(),
111+
NSPID: uint32(nspid),
112+
CgrpFsMagic: cgroupFsMagic,
110113
}
111114

112115
err = m.Update(k, v)
@@ -119,10 +122,12 @@ func UpdateTgRuntimeConf(mapDir string, nspid int) error {
119122
log.WithFields(logrus.Fields{
120123
"confmap-update": configMap.Name,
121124
"deployment.mode": cgroups.DeploymentCode(deployMode).String(),
122-
"cgroup.fs.magic": cgroups.CgroupFsMagicStr(cgroupFsMagic),
125+
"log.level": logrus.Level(v.LogLevel).String(),
126+
"cgroup.fs.magic": cgroups.CgroupFsMagicStr(v.CgrpFsMagic),
123127
"cgroup.controller.name": cgroups.GetCgrpControllerName(),
124128
"cgroup.controller.hierarchyID": v.TgCgrpHierarchy,
125129
"cgroup.controller.index": v.TgCgrpSubsysIdx,
130+
"NSPID": nspid,
126131
}).Info("Updated TetragonConf map successfully")
127132

128133
return nil

0 commit comments

Comments
 (0)