Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

*: fix InContainer check for cgroup v2 #51669

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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