Skip to content

Commit

Permalink
containermetadata: fix container ID parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandem committed Aug 8, 2024
1 parent e19abfc commit 8295735
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions containermetadata/containermetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ var (
dockerBuildkitPattern = regexp.MustCompile(`\d+:.*:/.*/*docker/buildkit/([0-9a-z]+)`)
lxcPattern = regexp.MustCompile(`\d+::/lxc\.(monitor|payload)\.([a-zA-Z]+)/`)
containerdPattern = regexp.MustCompile(`\d+:.+:/([a-zA-Z0-9_-]+)/+([a-zA-Z0-9_-]+)`)
defaultPattern = regexp.MustCompile(`^.*/(?:.*[-:])?([0-9a-f]+)(?:\.|\s*$)`)

containerIDPattern = regexp.MustCompile(`.+://([0-9a-f]{64})`)
defaultPattern = regexp.MustCompile(`^.*/(?:.*[-:])?` +
containerIDPatternStr + `(?:\.|\s*$)`)

containerIDPatternStr = `([0-9a-f]{64})|([0-9a-f]{32}-\\d+)|([0-9a-f]{8}(-[0-9a-f]{4}){4}$)`
// ContainerRegexpStr defines the regexp used to match container IDs
// ([0-9a-f]{64}) is standard container id used pretty much everywhere
// ([0-9a-f]{32}-\d+) is container id used by AWS ECS
// ([0-9a-f]{8}(-[0-9a-f]{4}){4}$) is container id used by Garden
containerIDPattern = regexp.MustCompile(containerIDPatternStr)

cgroup = "/proc/%d/cgroup"

Expand Down

0 comments on commit 8295735

Please sign in to comment.