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
0b45e324
Commit
0b45e324
authored
Nov 24, 2020
by
Akihiro Suda
Committed by
Brad Davidson
Nov 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support cgroup v2
Signed-off-by:
Akihiro Suda
<
akihiro.suda.cz@hco.ntt.co.jp
>
parent
36230daa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
go.mod
go.mod
+1
-0
run.go
pkg/agent/run.go
+31
-0
modules.txt
vendor/modules.txt
+1
-0
No files found.
go.mod
View file @
0b45e324
...
@@ -64,6 +64,7 @@ require (
...
@@ -64,6 +64,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/bronze1man/goStrongswanVici v0.0.0-20190828090544-27d02f80ba40 // indirect
github.com/bronze1man/goStrongswanVici v0.0.0-20190828090544-27d02f80ba40 // indirect
github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340
github.com/containerd/containerd v1.4.1
github.com/containerd/containerd v1.4.1
github.com/containerd/cri v1.11.1-0.20200820101445-b0cc07999aa5
github.com/containerd/cri v1.11.1-0.20200820101445-b0cc07999aa5
github.com/coreos/flannel v0.12.0
github.com/coreos/flannel v0.12.0
...
...
pkg/agent/run.go
View file @
0b45e324
...
@@ -3,12 +3,15 @@ package agent
...
@@ -3,12 +3,15 @@ package agent
import
(
import
(
"context"
"context"
"errors"
"errors"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
"strings"
"time"
"time"
"github.com/containerd/cgroups"
cgroupsv2
"github.com/containerd/cgroups/v2"
systemd
"github.com/coreos/go-systemd/daemon"
systemd
"github.com/coreos/go-systemd/daemon"
"github.com/rancher/k3s/pkg/agent/config"
"github.com/rancher/k3s/pkg/agent/config"
"github.com/rancher/k3s/pkg/agent/containerd"
"github.com/rancher/k3s/pkg/agent/containerd"
...
@@ -170,6 +173,13 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
...
@@ -170,6 +173,13 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
}
}
func
validate
()
error
{
func
validate
()
error
{
if
cgroups
.
Mode
()
==
cgroups
.
Unified
{
return
validateCgroupsV2
()
}
return
validateCgroupsV1
()
}
func
validateCgroupsV1
()
error
{
cgroups
,
err
:=
ioutil
.
ReadFile
(
"/proc/self/cgroup"
)
cgroups
,
err
:=
ioutil
.
ReadFile
(
"/proc/self/cgroup"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -188,6 +198,27 @@ func validate() error {
...
@@ -188,6 +198,27 @@ func validate() error {
return
nil
return
nil
}
}
func
validateCgroupsV2
()
error
{
manager
,
err
:=
cgroupsv2
.
LoadManager
(
"/sys/fs/cgroup"
,
"/"
)
if
err
!=
nil
{
return
err
}
controllers
,
err
:=
manager
.
RootControllers
()
if
err
!=
nil
{
return
err
}
m
:=
make
(
map
[
string
]
struct
{})
for
_
,
controller
:=
range
controllers
{
m
[
controller
]
=
struct
{}{}
}
for
_
,
controller
:=
range
[]
string
{
"cpu"
,
"cpuset"
,
"memory"
}
{
if
_
,
ok
:=
m
[
controller
];
!
ok
{
return
fmt
.
Errorf
(
"faild to find %s cgroup (v2)"
,
controller
)
}
}
return
nil
}
func
configureNode
(
ctx
context
.
Context
,
agentConfig
*
daemonconfig
.
Agent
,
nodes
v1
.
NodeInterface
)
error
{
func
configureNode
(
ctx
context
.
Context
,
agentConfig
*
daemonconfig
.
Agent
,
nodes
v1
.
NodeInterface
)
error
{
count
:=
0
count
:=
0
for
{
for
{
...
...
vendor/modules.txt
View file @
0b45e324
...
@@ -166,6 +166,7 @@ github.com/cilium/ebpf/internal/unix
...
@@ -166,6 +166,7 @@ github.com/cilium/ebpf/internal/unix
# github.com/container-storage-interface/spec v1.2.0
# github.com/container-storage-interface/spec v1.2.0
github.com/container-storage-interface/spec/lib/go/csi
github.com/container-storage-interface/spec/lib/go/csi
# github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340 => github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59
# github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340 => github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59
## explicit
github.com/containerd/cgroups
github.com/containerd/cgroups
github.com/containerd/cgroups/stats/v1
github.com/containerd/cgroups/stats/v1
github.com/containerd/cgroups/v2
github.com/containerd/cgroups/v2
...
...
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