Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
369f93f3
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
369f93f3
编写于
2月 18, 2021
作者:
M
Medya Ghazizadeh
提交者:
GitHub
2月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10468 from afbjorklund/cgroups-warning
Make sure to show debian warning also for cgroup 2
上级
5c9c0f96
2c87f6e1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
8 deletion
+83
-8
pkg/drivers/kic/oci/cgroups_linux.go
pkg/drivers/kic/oci/cgroups_linux.go
+34
-0
pkg/drivers/kic/oci/cgroups_other.go
pkg/drivers/kic/oci/cgroups_other.go
+30
-0
pkg/drivers/kic/oci/oci.go
pkg/drivers/kic/oci/oci.go
+19
-8
未找到文件。
pkg/drivers/kic/oci/cgroups_linux.go
0 → 100644
浏览文件 @
369f93f3
// +build linux
/*
Copyright 2021 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
oci
import
(
"syscall"
"golang.org/x/sys/unix"
)
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func
IsCgroup2UnifiedMode
()
(
bool
,
error
)
{
var
st
syscall
.
Statfs_t
if
err
:=
syscall
.
Statfs
(
"/sys/fs/cgroup"
,
&
st
);
err
!=
nil
{
return
false
,
err
}
return
st
.
Type
==
unix
.
CGROUP2_SUPER_MAGIC
,
nil
}
pkg/drivers/kic/oci/cgroups_other.go
0 → 100644
浏览文件 @
369f93f3
// +build !linux
/*
Copyright 2021 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
oci
import
(
"runtime"
"github.com/pkg/errors"
)
// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func
IsCgroup2UnifiedMode
()
(
bool
,
error
)
{
return
false
,
errors
.
Errorf
(
"Not supported on %s"
,
runtime
.
GOOS
)
}
pkg/drivers/kic/oci/oci.go
浏览文件 @
369f93f3
...
@@ -107,6 +107,24 @@ func PrepareContainerNode(p CreateParams) error {
...
@@ -107,6 +107,24 @@ func PrepareContainerNode(p CreateParams) error {
return
nil
return
nil
}
}
func
hasMemorySwapCgroup
()
bool
{
memcgSwap
:=
true
if
runtime
.
GOOS
==
"linux"
{
var
memoryswap
string
if
cgroup2
,
err
:=
IsCgroup2UnifiedMode
();
err
==
nil
&&
cgroup2
{
memoryswap
=
"/sys/fs/cgroup/memory/memory.swap.max"
}
else
{
memoryswap
=
"/sys/fs/cgroup/memory/memsw.limit_in_bytes"
}
if
_
,
err
:=
os
.
Stat
(
memoryswap
);
os
.
IsNotExist
(
err
)
{
// requires CONFIG_MEMCG_SWAP_ENABLED or cgroup_enable=memory in grub
klog
.
Warning
(
"Your kernel does not support swap limit capabilities or the cgroup is not mounted."
)
memcgSwap
=
false
}
}
return
memcgSwap
}
// CreateContainerNode creates a new container node
// CreateContainerNode creates a new container node
func
CreateContainerNode
(
p
CreateParams
)
error
{
func
CreateContainerNode
(
p
CreateParams
)
error
{
// on windows os, if docker desktop is using Windows Containers. Exit early with error
// on windows os, if docker desktop is using Windows Containers. Exit early with error
...
@@ -152,14 +170,7 @@ func CreateContainerNode(p CreateParams) error {
...
@@ -152,14 +170,7 @@ func CreateContainerNode(p CreateParams) error {
runArgs
=
append
(
runArgs
,
"--ip"
,
p
.
IP
)
runArgs
=
append
(
runArgs
,
"--ip"
,
p
.
IP
)
}
}
memcgSwap
:=
true
memcgSwap
:=
hasMemorySwapCgroup
()
if
runtime
.
GOOS
==
"linux"
{
if
_
,
err
:=
os
.
Stat
(
"/sys/fs/cgroup/memory/memsw.limit_in_bytes"
);
os
.
IsNotExist
(
err
)
{
// requires CONFIG_MEMCG_SWAP_ENABLED or cgroup_enable=memory in grub
klog
.
Warning
(
"Your kernel does not support swap limit capabilities or the cgroup is not mounted."
)
memcgSwap
=
false
}
}
// https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
// https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
var
virtualization
string
var
virtualization
string
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录