Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
11711205
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
11711205
编写于
6月 15, 2020
作者:
L
lifeng68
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resources: support inspect memory-swap
Signed-off-by:
N
lifeng68
<
lifeng68@huawei.com
>
上级
d943fc8e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
3 deletion
+66
-3
CI/test_cases/basic_cases/update.bash
CI/test_cases/basic_cases/update.bash
+31
-1
src/services/execution/execute/execution_create.c
src/services/execution/execute/execution_create.c
+32
-0
src/services/execution/execute/execution_extend.c
src/services/execution/execute/execution_extend.c
+3
-2
未找到文件。
CI/test_cases/basic_cases/update.bash
浏览文件 @
11711205
...
...
@@ -26,7 +26,7 @@ source ./helpers.bash
function
do_test_t
()
{
containername
=
test_update
containerid
=
`
isula create
-t
--name
$containername
busybox
`
containerid
=
`
isula create
-t
--
memory
50M
--
name
$containername
busybox
`
fn_check_eq
"
$?
"
"0"
"create failed"
testcontainer
$containername
inited
...
...
@@ -117,6 +117,29 @@ function do_test_t()
return
$TC_RET_T
}
function
do_test_t1
()
{
containername
=
test_update1
containerid
=
`
isula run
-itd
--memory
500M
--name
$containername
busybox
`
fn_check_eq
"
$?
"
"0"
"run failed"
isula inspect
$containerid
|
grep
"MemorySwap"
|
grep
"1048576000"
fn_check_eq
"
$?
"
"0"
"inspect memory swap failed"
isula update
--memory
2G
$containername
>
/tmp/test_update1.log 2>&1
fn_check_eq
"
$?
"
"1"
"Success update memory with 2G, expect fail"
cat
/tmp/test_update1.log |
grep
"Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time."
fn_check_eq
"
$?
"
"0"
"Failed to check error message"
rm
-rf
/tmp/test_update1.log
isula
rm
-f
$containername
fn_check_eq
"
$?
"
"0"
"rm failed"
return
$TC_RET_T
}
ret
=
0
do_test_t
...
...
@@ -124,4 +147,11 @@ if [ $? -ne 0 ];then
let
"ret=
$ret
+ 1"
fi
if
[
-f
"/sys/fs/cgroup/memory/memory.memsw.usage_in_bytes"
]
;
then
do_test_t1
if
[
$?
-ne
0
]
;
then
let
"ret=
$ret
+ 1"
fi
fi
show_result
$ret
"basic update"
src/services/execution/execute/execution_create.c
浏览文件 @
11711205
...
...
@@ -45,6 +45,7 @@
#include "constants.h"
#include "namespace.h"
#include "collector.h"
#include "sysinfo.h"
static
int
runtime_check
(
const
char
*
name
,
bool
*
runtime_res
)
{
...
...
@@ -837,6 +838,33 @@ static int preparate_runtime_environment(const container_create_request *request
return
0
;
}
static
int
adapt_host_spec
(
host_config
*
host_spec
)
{
int
ret
=
0
;
sysinfo_t
*
sysinfo
=
NULL
;
sysinfo
=
get_sys_info
(
true
);
if
(
sysinfo
==
NULL
)
{
ERROR
(
"Can not get system info"
);
ret
=
-
1
;
goto
out
;
}
if
(
host_spec
->
memory
>
0
&&
host_spec
->
memory_swap
==
0
&&
sysinfo
->
cgmeminfo
.
swap
)
{
if
(
host_spec
->
memory
>
(
INT64_MAX
/
2
))
{
ERROR
(
"Memory swap out of range!"
);
isulad_set_error_message
(
"Memory swap out of range!"
);
ret
=
-
1
;
goto
out
;
}
host_spec
->
memory_swap
=
host_spec
->
memory
*
2
;
}
out:
free_sysinfo
(
sysinfo
);
return
ret
;
}
static
int
get_basic_spec
(
const
container_create_request
*
request
,
const
char
*
id
,
const
char
*
runtime_root
,
host_config
**
host_spec
,
container_config
**
container_spec
)
{
...
...
@@ -845,6 +873,10 @@ static int get_basic_spec(const container_create_request *request, const char *i
return
-
1
;
}
if
(
adapt_host_spec
(
*
host_spec
)
!=
0
)
{
return
-
1
;
}
*
container_spec
=
get_container_spec
(
id
,
runtime_root
,
request
);
if
(
*
container_spec
==
NULL
)
{
return
-
1
;
...
...
src/services/execution/execute/execution_extend.c
浏览文件 @
11711205
...
...
@@ -863,8 +863,9 @@ static int update_container_memory(const char *id, const host_config *hostconfig
hostconfig
->
memory_swap
==
0
)
{
ERROR
(
"Memory limit should be smaller than already set memoryswap limit,"
" update the memoryswap at the same time"
);
isulad_set_error_message
(
"Cannot update container %s: Memory limit should be smaller than"
"already set memoryswap limit, update the memoryswap at the same time."
,
id
);
isulad_set_error_message
(
"Cannot update container %s: Memory limit should be smaller than "
"already set memoryswap limit, update the memoryswap at the same time."
,
id
);
ret
=
-
1
;
goto
out
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录