Skip to content

Commit

Permalink
Adhoc fix for crio
Browse files Browse the repository at this point in the history
CRIO currently does not add .containerenv files into containers.
xref: cri-o/cri-o#5461
  • Loading branch information
pjbgf committed Nov 17, 2021
1 parent 4091e5c commit d7eeecc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/hostop/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ func InsideContainer() bool {
return true
}
}
return checkCgroup()
}

// checkCgroup checks the cgroup file for the crio signature
// this is a temporary fix until support is added upstream.
func checkCgroup() bool {
f, err := os.Open("/proc/self/cgroup")
if err != nil {
return false
}
defer f.Close()

scanner := bufio.NewScanner(f)

for scanner.Scan() {
if strings.Contains(scanner.Text(), "crio-") {
return true
}

if err := scanner.Err(); err != nil {
break
}
}
return false
}

Expand Down

0 comments on commit d7eeecc

Please sign in to comment.