Skip to content

Commit

Permalink
*: fix InContainer check for cgroup v2 (#51669)
Browse files Browse the repository at this point in the history
close #51668
  • Loading branch information
D3Hunter authored Mar 12, 2024
1 parent 69ab2a4 commit 2d57833
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/util/cgroup/cgroup_cpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ func inContainer(path string) bool {
lines := strings.Split(string(v), "\n")
for _, line := range lines {
v := strings.Split(line, " ")
// check mount point is on overlay or not.
// check mount point of root dir is on overlay or not.
// v[4] means `mount point`, v[8] means `filesystem type`.
// see details from https://man7.org/linux/man-pages/man5/proc.5.html
if len(v) >= 8 && v[4] == "\\" && v[8] == "overlay" {
// TODO: enhance this check, as overlay is not the only storage driver for container.
if len(v) > 8 && v[4] == "/" && v[8] == "overlay" {
log.Info(fmt.Sprintf("TiDB runs in a container, mount info: %s", line))
return true
}
Expand Down

0 comments on commit 2d57833

Please sign in to comment.