Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

policyfilter fix #2188

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cmd/tetra/policyfilter/policyfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package policyfilter

import (
"fmt"
"path/filepath"
"strconv"

Expand All @@ -26,11 +27,32 @@ func New() *cobra.Command {
ret.AddCommand(
dumpCmd(),
addCommand(),
cgroupGetIDCommand(),
)

return ret
}

func cgroupGetIDCommand() *cobra.Command {
mapFname := filepath.Join(defaults.DefaultMapRoot, defaults.DefaultMapPrefix, policyfilter.MapName)
ret := &cobra.Command{
Use: "cgroupid",
Short: "retrieve cgroup id from file",
Args: cobra.ExactArgs(1),
Run: func(_ *cobra.Command, args []string) {
cgID, err := cgroups.GetCgroupIdFromPath(args[0])
if err != nil {
logger.GetLogger().WithError(err).Fatal("Failed to parse cgroup")
}
fmt.Printf("%d\n", cgID)
},
}

flags := ret.Flags()
flags.StringVar(&mapFname, "map-fname", mapFname, "policyfilter map filename")
return ret
}

func dumpCmd() *cobra.Command {
mapFname := filepath.Join(defaults.DefaultMapRoot, defaults.DefaultMapPrefix, policyfilter.MapName)
ret := &cobra.Command{
Expand Down
4 changes: 4 additions & 0 deletions pkg/cgroups/fsscan/fsscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func findContainerDirectory(podpath string, containerID string) string {
}

name := dentry.Name()
// skip crio's conmon container
if strings.Contains(name, "crio-conmon") {
continue
}
if strings.Contains(name, containerID) {
return name
}
Expand Down
Loading