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
4bba0402
Commit
4bba0402
authored
Apr 12, 2019
by
Erik Wilson
Committed by
Erik Wilson
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for cgroup pids support
If cgroup pids are not supported add a feature-gates flag SupportPodPidsLimit=false for kubelet.
parent
af2fc722
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
agent.go
pkg/daemons/agent/agent.go
+22
-9
No files found.
pkg/daemons/agent/agent.go
View file @
4bba0402
...
@@ -101,17 +101,23 @@ func kubelet(cfg *config.Agent) {
...
@@ -101,17 +101,23 @@ func kubelet(cfg *config.Agent) {
if
err
!=
nil
||
defaultIP
.
String
()
!=
cfg
.
NodeIP
{
if
err
!=
nil
||
defaultIP
.
String
()
!=
cfg
.
NodeIP
{
argsMap
[
"node-ip"
]
=
cfg
.
NodeIP
argsMap
[
"node-ip"
]
=
cfg
.
NodeIP
}
}
root
,
hasCFS
:=
checkCgroups
()
root
,
hasCFS
,
hasPIDs
:=
checkCgroups
()
if
!
hasCFS
{
if
!
hasCFS
{
logrus
.
Warn
(
"Disabling CPU quotas due to missing cpu.cfs_period_us"
)
logrus
.
Warn
(
"Disabling CPU quotas due to missing cpu.cfs_period_us"
)
argsMap
[
"cpu-cfs-quota"
]
=
"false"
argsMap
[
"cpu-cfs-quota"
]
=
"false"
}
}
if
!
hasPIDs
{
logrus
.
Warn
(
"Disabling pod PIDs limit feature due to missing cgroup pids support"
)
argsMap
[
"cgroups-per-qos"
]
=
"false"
argsMap
[
"enforce-node-allocatable"
]
=
""
argsMap
[
"feature-gates"
]
=
addFeatureGate
(
argsMap
[
"feature-gates"
],
"SupportPodPidsLimit=false"
)
}
if
root
!=
""
{
if
root
!=
""
{
argsMap
[
"runtime-cgroups"
]
=
root
argsMap
[
"runtime-cgroups"
]
=
root
argsMap
[
"kubelet-cgroups"
]
=
root
argsMap
[
"kubelet-cgroups"
]
=
root
}
}
if
system
.
RunningInUserNS
()
{
if
system
.
RunningInUserNS
()
{
argsMap
[
"feature-gates"
]
=
"DevicePlugins=false"
argsMap
[
"feature-gates"
]
=
addFeatureGate
(
argsMap
[
"feature-gates"
],
"DevicePlugins=false"
)
}
}
args
:=
config
.
GetArgsList
(
argsMap
,
cfg
.
ExtraKubeletArgs
)
args
:=
config
.
GetArgsList
(
argsMap
,
cfg
.
ExtraKubeletArgs
)
...
@@ -123,15 +129,20 @@ func kubelet(cfg *config.Agent) {
...
@@ -123,15 +129,20 @@ func kubelet(cfg *config.Agent) {
}()
}()
}
}
func
checkCgroups
()
(
string
,
bool
)
{
func
addFeatureGate
(
current
,
new
string
)
string
{
if
current
==
""
{
return
new
}
return
current
+
","
+
new
}
func
checkCgroups
()
(
root
string
,
hasCFS
bool
,
hasPIDs
bool
)
{
f
,
err
:=
os
.
Open
(
"/proc/self/cgroup"
)
f
,
err
:=
os
.
Open
(
"/proc/self/cgroup"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
false
return
""
,
false
,
false
}
}
defer
f
.
Close
()
defer
f
.
Close
()
ret
:=
false
root
:=
""
scan
:=
bufio
.
NewScanner
(
f
)
scan
:=
bufio
.
NewScanner
(
f
)
for
scan
.
Scan
()
{
for
scan
.
Scan
()
{
parts
:=
strings
.
Split
(
scan
.
Text
(),
":"
)
parts
:=
strings
.
Split
(
scan
.
Text
(),
":"
)
...
@@ -140,10 +151,12 @@ func checkCgroups() (string, bool) {
...
@@ -140,10 +151,12 @@ func checkCgroups() (string, bool) {
}
}
systems
:=
strings
.
Split
(
parts
[
1
],
","
)
systems
:=
strings
.
Split
(
parts
[
1
],
","
)
for
_
,
system
:=
range
systems
{
for
_
,
system
:=
range
systems
{
if
system
==
"cpu"
{
if
system
==
"pids"
{
hasPIDs
=
true
}
else
if
system
==
"cpu"
{
p
:=
filepath
.
Join
(
"/sys/fs/cgroup"
,
parts
[
1
],
parts
[
2
],
"cpu.cfs_period_us"
)
p
:=
filepath
.
Join
(
"/sys/fs/cgroup"
,
parts
[
1
],
parts
[
2
],
"cpu.cfs_period_us"
)
if
_
,
err
:=
os
.
Stat
(
p
);
err
==
nil
{
if
_
,
err
:=
os
.
Stat
(
p
);
err
==
nil
{
ret
=
true
hasCFS
=
true
}
}
}
else
if
system
==
"name=systemd"
{
}
else
if
system
==
"name=systemd"
{
last
:=
parts
[
len
(
parts
)
-
1
]
last
:=
parts
[
len
(
parts
)
-
1
]
...
@@ -155,5 +168,5 @@ func checkCgroups() (string, bool) {
...
@@ -155,5 +168,5 @@ func checkCgroups() (string, bool) {
}
}
}
}
return
root
,
ret
return
root
,
hasCFS
,
hasPIDs
}
}
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