diff --git a/pkg/cgidmap/cgidmap.go b/pkg/cgidmap/cgidmap.go index 1e55a48f391..529fe19487c 100644 --- a/pkg/cgidmap/cgidmap.go +++ b/pkg/cgidmap/cgidmap.go @@ -8,7 +8,6 @@ package cgidmap import ( - "errors" "sync" "github.com/cilium/tetragon/pkg/logger" @@ -249,12 +248,20 @@ var ( setGlMap sync.Once ) +type cgidDisabledTy struct{} + +var cgidDisabled = &cgidDisabledTy{} + +func (e *cgidDisabledTy) Error() string { + return "cgidmap disabled" +} + // GetState returns the global map func GlobalMap() (Map, error) { setGlMap.Do(func() { if !option.Config.EnableCgIDmap { glMap = nil - glError = errors.New("cgidmap disabled") + glError = cgidDisabled return } diff --git a/pkg/cgidmap/podhooks.go b/pkg/cgidmap/podhooks.go index 47874711099..6082e0eae41 100644 --- a/pkg/cgidmap/podhooks.go +++ b/pkg/cgidmap/podhooks.go @@ -4,6 +4,8 @@ package cgidmap import ( + "errors" + "github.com/cilium/tetragon/pkg/logger" "github.com/cilium/tetragon/pkg/podhelpers" "github.com/cilium/tetragon/pkg/podhooks" @@ -26,7 +28,10 @@ func registerPodCallbacks(podInformer cache.SharedIndexInformer) { m, err := GlobalMap() if err != nil { - logger.GetLogger().WithError(err).Warn("failed to retrieve cgidmap, not registering rthook") + // if cgidmap is disabled, an error is expected so do not omit a warning + if !errors.Is(err, cgidDisabled) { + logger.GetLogger().WithError(err).Warn("failed to retrieve cgidmap, not registering podhook") + } return }