Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
84a8ed26
Commit
84a8ed26
authored
May 28, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26478 from kubernetes/revert-25982-fix_stats
Revert "Fix system container detection in kubelet on systemd"
parents
e543bd64
fcfaf1a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
35 deletions
+5
-35
container_manager_linux.go
pkg/kubelet/cm/container_manager_linux.go
+5
-35
No files found.
pkg/kubelet/cm/container_manager_linux.go
View file @
84a8ed26
...
...
@@ -536,49 +536,19 @@ func ensureProcessInContainer(pid int, oomScoreAdj int, manager *fs.Manager) err
return
utilerrors
.
NewAggregate
(
errs
)
}
// getContainer returns the cgroup associated with the specified pid.
// It enforces a unified hierarchy for memory and cpu cgroups.
// On systemd environments, it uses the name=systemd cgroup for the specified pid.
// Gets the (CPU) container the specified pid is in.
func
getContainer
(
pid
int
)
(
string
,
error
)
{
cgs
,
err
:=
cgroups
.
ParseCgroupFile
(
fmt
.
Sprintf
(
"/proc/%d/cgroup"
,
pid
))
if
err
!=
nil
{
return
""
,
err
}
cpu
,
found
:=
cgs
[
"cpu"
]
if
!
found
{
return
""
,
cgroups
.
NewNotFoundError
(
"cpu"
)
}
memory
,
found
:=
cgs
[
"memory"
]
if
!
found
{
return
""
,
cgroups
.
NewNotFoundError
(
"memory"
)
}
// since we use this container for accounting, we need to ensure its a unified hierarchy.
if
cpu
!=
memory
{
return
""
,
fmt
.
Errorf
(
"cpu and memory cgroup hierarchy not unified. cpu: %s, memory: %s"
,
cpu
,
memory
)
}
// on systemd, every pid is in a unified cgroup hierarchy (name=systemd as seen in systemd-cgls)
// cpu and memory accounting is off by default, users may choose to enable it per unit or globally.
// users could enable CPU and memory accounting globally via /etc/systemd/system.conf (DefaultCPUAccounting=true DefaultMemoryAccounting=true).
// users could also enable CPU and memory accounting per unit via CPUAccounting=true and MemoryAccounting=true
// we only warn if accounting is not enabled for CPU or memory so as to not break local development flows where kubelet is launched in a terminal.
// for example, the cgroup for the user session will be something like /user.slice/user-X.slice/session-X.scope, but the cpu and memory
// cgroup will be the closest ancestor where accounting is performed (most likely /) on systems that launch docker containers.
// as a result, on those systems, you will not get cpu or memory accounting statistics for kubelet.
// in addition, you would not get memory or cpu accounting for the runtime unless accounting was enabled on its unit (or globally).
if
systemd
,
found
:=
cgs
[
"name=systemd"
];
found
{
if
systemd
!=
cpu
{
glog
.
Warningf
(
"CPUAccounting not enabled for pid: %d"
,
pid
)
}
if
systemd
!=
memory
{
glog
.
Warningf
(
"MemoryAccounting not enabled for pid: %d"
,
pid
)
}
return
systemd
,
nil
cg
,
ok
:=
cgs
[
"cpu"
]
if
ok
{
return
cg
,
nil
}
return
cpu
,
nil
return
""
,
cgroups
.
NewNotFoundError
(
"cpu"
)
}
// Ensures the system container is created and all non-kernel threads and process 1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment