Skip to content

Commit

Permalink
Merge branch 'main' into filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Sep 2, 2024
2 parents 274e745 + 2f6256e commit c7aea5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Release Notes.
* Upgrade LLVM to `18`.
* Support propagation the excluding namespaces in the access log to the backend.
* Add `pprof` module for observe self.
* Add detect process from `CRI-O` container in Kubernetes.
* Introduce `MonitorFilter` into access log module.

#### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions pkg/process/finders/kubernetes/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (c *PodContainer) CGroupID() string {
cgroupID = strings.TrimPrefix(cgroupID, "containerd://")
cgroupID = strings.TrimPrefix(cgroupID, "dockerd://")
cgroupID = strings.TrimPrefix(cgroupID, "docker://")
cgroupID = strings.TrimPrefix(cgroupID, "cri-o://")
return cgroupID
}

Expand Down
23 changes: 7 additions & 16 deletions pkg/process/finders/kubernetes/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ import (

var log = logger.GetLogger("process", "finder", "kubernetes")

var kubepodsRegex = regexp.MustCompile(`cri-containerd-(?P<Group>\w+)\.scope`)
var (
kubepodsRegex = regexp.MustCompile(`cri-containerd-(?P<Group>\w+)\.scope`)
openShiftPodsRegex = regexp.MustCompile(`crio-(?P<Group>\w+)\.scope`)
)

type ProcessFinder struct {
conf *Config
Expand Down Expand Up @@ -289,6 +292,9 @@ func (f *ProcessFinder) getProcessCGroup(pid int32) ([]string, error) {
if kubepod := kubepodsRegex.FindStringSubmatch(path); len(kubepod) >= 1 {
path = kubepod[1]
}
if openShiftPod := openShiftPodsRegex.FindStringSubmatch(path); len(openShiftPod) >= 1 {
path = openShiftPod[1]
}
cache[path] = true
}
}
Expand Down Expand Up @@ -382,21 +388,6 @@ func (f *ProcessFinder) ParseProcessID(ps api.DetectedProcess, downstream *v3.EB
}

func (f *ProcessFinder) ShouldMonitor(pid int32) bool {
pidList, err := process.Pids()
if err != nil {
return false
}
pidExist := false
for _, p := range pidList {
if p == pid {
pidExist = true
break
}
}
if !pidExist {
return false
}

newProcess, err := process.NewProcess(pid)
if err != nil {
return false
Expand Down

0 comments on commit c7aea5a

Please sign in to comment.