Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
5d51de78
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,发现更多精彩内容 >>
提交
5d51de78
编写于
2月 08, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
2月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
!39 iSulad: resume container when do gc
Merge pull request !39 from lifeng_isula/fix_gc
上级
88b9ddd3
7bf2be0a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
3 deletion
+60
-3
src/services/execution/execute/execution_extend.c
src/services/execution/execute/execution_extend.c
+2
-2
src/services/execution/manager/containers_gc.c
src/services/execution/manager/containers_gc.c
+53
-0
src/services/execution/manager/restore.c
src/services/execution/manager/restore.c
+5
-1
未找到文件。
src/services/execution/execute/execution_extend.c
浏览文件 @
5d51de78
...
...
@@ -498,7 +498,7 @@ pack_response:
return
(
cc
==
ISULAD_SUCCESS
)
?
0
:
-
1
;
}
static
int
resume_container
(
container_t
*
cont
)
static
int
do_
resume_container
(
container_t
*
cont
)
{
int
ret
=
0
;
const
char
*
id
=
cont
->
common_config
->
id
;
...
...
@@ -662,7 +662,7 @@ static int container_resume_cb(const container_resume_request *request, containe
goto
pack_response
;
}
ret
=
resume_container
(
cont
);
ret
=
do_
resume_container
(
cont
);
if
(
ret
!=
0
)
{
cc
=
ISULAD_ERR_EXEC
;
container_state_set_error
(
cont
->
state
,
(
const
char
*
)
g_isulad_errmsg
);
...
...
src/services/execution/manager/containers_gc.c
浏览文件 @
5d51de78
...
...
@@ -25,6 +25,7 @@
#include "utils.h"
#include "execution.h"
#include "containers_store.h"
#include "runtime.h"
static
containers_gc_t
g_gc_containers
;
...
...
@@ -385,6 +386,57 @@ static void add_to_list_tail_to_retry_gc(struct linked_list *it)
gc_containers_unlock
();
}
static
int
do_runtime_resume_container
(
const
container_t
*
cont
)
{
int
ret
=
0
;
rt_resume_params_t
params
=
{
0
};
const
char
*
id
=
cont
->
common_config
->
id
;
params
.
rootpath
=
cont
->
root_path
;
if
(
runtime_resume
(
id
,
cont
->
runtime
,
&
params
))
{
ERROR
(
"Failed to resume container:%s"
,
id
);
ret
=
-
1
;
goto
out
;
}
state_reset_paused
(
cont
->
state
);
if
(
container_to_disk
(
cont
))
{
ERROR
(
"Failed to save container
\"
%s
\"
to disk"
,
id
);
ret
=
-
1
;
goto
out
;
}
out:
return
ret
;
}
static
void
try_to_resume_container
(
const
char
*
id
,
const
char
*
runtime
)
{
int
ret
=
0
;
container_t
*
cont
=
NULL
;
if
(
id
==
NULL
||
runtime
==
NULL
)
{
ERROR
(
"Invalid input arguments"
);
goto
out
;
}
cont
=
containers_store_get
(
id
);
if
(
cont
==
NULL
)
{
WARN
(
"No such container:%s"
,
id
);
goto
out
;
}
ret
=
do_runtime_resume_container
(
cont
);
if
(
ret
!=
0
)
{
ERROR
(
"try to runtime resume failed"
);
goto
out
;
}
out:
container_unref
(
cont
);
}
static
void
gc_container_process
(
struct
linked_list
*
it
)
{
int
ret
=
0
;
...
...
@@ -424,6 +476,7 @@ static void gc_container_process(struct linked_list *it)
free_container_garbage_config_gc_containers_element
(
gc_cont
);
free
(
it
);
}
else
{
try_to_resume_container
(
id
,
runtime
);
ret
=
kill
(
pid
,
SIGKILL
);
if
(
ret
<
0
&&
errno
!=
ESRCH
)
{
ERROR
(
"Can not kill process (pid=%d) with SIGKILL for container %s"
,
pid
,
id
);
...
...
src/services/execution/manager/restore.c
浏览文件 @
5d51de78
...
...
@@ -205,10 +205,14 @@ static void try_to_set_container_running(Container_Status status, container_t *c
static
int
restore_stopped_container
(
Container_Status
status
,
const
container_t
*
cont
,
bool
*
need_save
)
{
const
char
*
id
=
cont
->
common_config
->
id
;
pid_t
pid
=
0
;
if
(
status
!=
CONTAINER_STATUS_STOPPED
&&
\
status
!=
CONTAINER_STATUS_CREATED
)
{
int
nret
=
post_stopped_container_to_gc
(
id
,
cont
->
runtime
,
cont
->
state_path
,
0
);
if
(
util_process_alive
(
cont
->
state
->
state
->
pid
,
cont
->
state
->
state
->
start_time
))
{
pid
=
cont
->
state
->
state
->
pid
;
}
int
nret
=
post_stopped_container_to_gc
(
id
,
cont
->
runtime
,
cont
->
state_path
,
pid
);
if
(
nret
!=
0
)
{
ERROR
(
"Failed to post container %s to garbage"
"collector, that may lost some resources"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录