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
6196098f
Unverified
Commit
6196098f
authored
Dec 08, 2020
by
Chris Kim
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2646 from Oats87/issues/k3s/2548-1-19
[Backport 1.19] Set a cgroup if containerized
parents
8f9e5628
0ecec442
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
agent.go
pkg/daemons/agent/agent.go
+24
-5
No files found.
pkg/daemons/agent/agent.go
View file @
6196098f
...
@@ -194,12 +194,31 @@ func checkCgroups() (root string, hasCFS bool, hasPIDs bool) {
...
@@ -194,12 +194,31 @@ func checkCgroups() (root string, hasCFS bool, hasPIDs bool) {
if
_
,
err
:=
os
.
Stat
(
p
);
err
==
nil
{
if
_
,
err
:=
os
.
Stat
(
p
);
err
==
nil
{
hasCFS
=
true
hasCFS
=
true
}
}
}
else
if
system
==
"name=systemd"
{
}
}
}
// Examine process ID 1 to see if there is a cgroup assigned to it.
// When we are not in a container, process 1 is likely to be systemd or some other service manager.
// When containerized, process 1 will be generally be in a cgroup, otherwise, we may be running in
// a host PID scenario but we don't support this.
g
,
err
:=
os
.
Open
(
"/proc/1/cgroup"
)
if
err
!=
nil
{
return
""
,
false
,
false
}
defer
g
.
Close
()
root
=
""
scan
=
bufio
.
NewScanner
(
g
)
for
scan
.
Scan
()
{
parts
:=
strings
.
Split
(
scan
.
Text
(),
":"
)
if
len
(
parts
)
<
3
{
continue
}
systems
:=
strings
.
Split
(
parts
[
1
],
","
)
for
_
,
system
:=
range
systems
{
if
system
==
"name=systemd"
{
last
:=
parts
[
len
(
parts
)
-
1
]
last
:=
parts
[
len
(
parts
)
-
1
]
i
:=
strings
.
LastIndex
(
last
,
".slice"
)
if
last
!=
"/"
{
if
i
>
0
{
root
=
"/systemd"
+
last
[
:
i
+
len
(
".slice"
)]
}
else
{
root
=
"/systemd"
root
=
"/systemd"
}
}
}
}
...
...
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