Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
4724df19
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,发现更多精彩内容 >>
提交
4724df19
编写于
3月 31, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
3月 31, 2020
浏览文件
操作
浏览文件
下载
差异文件
!135 isulad: support oci isula stats
Merge pull request !135 from jing-rui/dev
上级
3b2c1322
19045c9c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
140 addition
and
4 deletion
+140
-4
src/json/schema/schema/shim/client/runtime-stats.json
src/json/schema/schema/shim/client/runtime-stats.json
+54
-0
src/runtime/isula/isula_rt_ops.c
src/runtime/isula/isula_rt_ops.c
+80
-4
src/runtime/runtime.h
src/runtime/runtime.h
+1
-0
src/services/cri/cri_container.cc
src/services/cri/cri_container.cc
+4
-0
src/services/execution/execute/execution_extend.c
src/services/execution/execute/execution_extend.c
+1
-0
未找到文件。
src/json/schema/schema/shim/client/runtime-stats.json
0 → 100644
浏览文件 @
4724df19
{
"description"
:
"runtime stats"
,
"type"
:
"object"
,
"properties"
:
{
"data"
:
{
"type"
:
"object"
,
"properties"
:
{
"pids"
:
{
"type"
:
"object"
,
"properties"
:
{
"current"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
}
}
},
"cpu"
:
{
"type"
:
"object"
,
"properties"
:
{
"usage"
:
{
"type"
:
"object"
,
"properties"
:
{
"kernel"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
},
"user"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
},
"total"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
}
}
}
}
},
"memory"
:
{
"type"
:
"object"
,
"properties"
:
{
"usage"
:
{
"type"
:
"object"
,
"properties"
:
{
"usage"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
},
"limit"
:
{
"$ref"
:
"../../defs.json#/definitions/uint64"
}
}
}
}
}
}
}
}
}
src/runtime/isula/isula_rt_ops.c
浏览文件 @
4724df19
...
...
@@ -26,6 +26,7 @@
#include "engine.h"
#include "constants.h"
#include "shim_client_process_state.h"
#include "shim_client_runtime_stats.h"
#include "oci_runtime_state.h"
#include "isulad_config.h"
#include "utils_string.h"
...
...
@@ -505,6 +506,60 @@ out:
return
ret
;
}
static
int
runtime_call_stats
(
const
char
*
workdir
,
const
char
*
runtime
,
const
char
*
id
,
struct
engine_container_resources_stats_info
*
info
)
{
char
*
stdout
=
NULL
;
char
*
stderr
=
NULL
;
shim_client_runtime_stats
*
stats
=
NULL
;
struct
parser_context
ctx
=
{
OPT_GEN_SIMPLIFY
,
0
};
parser_error
perr
=
NULL
;
runtime_exec_info
rei
=
{
0
};
int
ret
=
0
;
char
*
params
[
PARAM_NUM
]
=
{
0
};
const
char
*
opts
[
1
]
=
{
"--stats"
};
runtime_exec_info_init
(
&
rei
,
workdir
,
runtime
,
"events"
,
opts
,
1
,
id
,
params
,
PARAM_NUM
);
if
(
!
util_exec_cmd
(
runtime_exec_func
,
&
rei
,
NULL
,
&
stdout
,
&
stderr
))
{
ERROR
(
"call runtime events --stats failed: %s"
,
stderr
);
ret
=
-
1
;
goto
out
;
}
if
(
stdout
==
NULL
)
{
ERROR
(
"call runtime events --stats no stdout"
);
ret
=
-
1
;
goto
out
;
}
stats
=
shim_client_runtime_stats_parse_data
(
stdout
,
&
ctx
,
&
perr
);
if
(
stats
==
NULL
)
{
ERROR
(
"call runtime events --stats parse json failed"
);
ret
=
-
1
;
goto
out
;
}
if
(
stats
!=
NULL
&&
stats
->
data
!=
NULL
&&
stats
->
data
->
pids
!=
NULL
)
{
info
->
pids_current
=
stats
->
data
->
pids
->
current
;
}
if
(
stats
!=
NULL
&&
stats
->
data
!=
NULL
&&
stats
->
data
->
cpu
!=
NULL
&&
stats
->
data
->
cpu
->
usage
)
{
info
->
cpu_use_nanos
=
stats
->
data
->
cpu
->
usage
->
total
;
info
->
cpu_system_use
=
stats
->
data
->
cpu
->
usage
->
kernel
;
}
if
(
stats
!=
NULL
&&
stats
->
data
!=
NULL
&&
stats
->
data
->
memory
!=
NULL
&&
stats
->
data
->
memory
->
usage
)
{
info
->
mem_used
=
stats
->
data
->
memory
->
usage
->
usage
;
info
->
mem_limit
=
stats
->
data
->
memory
->
usage
->
limit
;
}
out:
free_shim_client_runtime_stats
(
stats
);
UTIL_FREE_AND_SET_NULL
(
stdout
);
UTIL_FREE_AND_SET_NULL
(
stderr
);
UTIL_FREE_AND_SET_NULL
(
perr
);
return
ret
;
}
static
int
runtime_call_simple
(
const
char
*
workdir
,
const
char
*
runtime
,
const
char
*
subcmd
,
const
char
**
opts
,
size_t
opts_len
,
const
char
*
id
)
{
...
...
@@ -1095,13 +1150,34 @@ int rt_isula_listpids(const char *name, const char *runtime, const rt_listpids_p
return
-
1
;
}
int
rt_isula_resources_stats
(
const
char
*
name
,
const
char
*
runtime
,
int
rt_isula_resources_stats
(
const
char
*
id
,
const
char
*
runtime
,
const
rt_stats_params_t
*
params
,
struct
engine_container_resources_stats_info
*
rs_stats
)
{
ERROR
(
"isula stats not support on isulad-shim"
);
isulad_set_error_message
(
"isula stats not support on isulad-shim"
);
char
workdir
[
PATH_MAX
]
=
{
0
};
int
ret
=
0
;
if
(
id
==
NULL
||
runtime
==
NULL
||
params
==
NULL
||
rs_stats
==
NULL
)
{
ERROR
(
"nullptr arguments not allowed"
);
return
-
1
;
}
ret
=
snprintf
(
workdir
,
sizeof
(
workdir
),
"%s/%s"
,
params
->
state
,
id
);
if
(
ret
<
0
)
{
ERROR
(
"failed join full workdir %s/%s"
,
params
->
rootpath
,
id
);
goto
out
;
}
if
(
!
shim_alive
(
workdir
))
{
ERROR
(
"shim dead %s"
,
workdir
);
ret
=
-
1
;
goto
out
;
}
ret
=
runtime_call_stats
(
workdir
,
runtime
,
id
,
rs_stats
);
out:
return
ret
;
}
int
rt_isula_resize
(
const
char
*
id
,
const
char
*
runtime
,
const
rt_resize_params_t
*
params
)
...
...
src/runtime/runtime.h
浏览文件 @
4724df19
...
...
@@ -82,6 +82,7 @@ typedef struct _rt_status_params_t {
typedef
struct
_rt_stats_params_t
{
const
char
*
rootpath
;
const
char
*
state
;
}
rt_stats_params_t
;
typedef
struct
_rt_exec_params_t
{
...
...
src/services/cri/cri_container.cc
浏览文件 @
4724df19
...
...
@@ -867,6 +867,10 @@ void CRIRuntimeServiceImpl::PackContainerStatsAttributes(
container
->
mutable_attributes
()
->
set_id
(
id
);
auto
status
=
ContainerStatus
(
std
::
string
(
id
),
error
);
if
(
status
==
nullptr
)
{
return
;
}
if
(
status
->
has_metadata
())
{
std
::
unique_ptr
<
runtime
::
v1alpha2
::
ContainerMetadata
>
metadata
(
new
(
std
::
nothrow
)
runtime
::
v1alpha2
::
ContainerMetadata
(
status
->
metadata
()));
...
...
src/services/execution/execute/execution_extend.c
浏览文件 @
4724df19
...
...
@@ -424,6 +424,7 @@ static int get_containers_stats(char **idsarray, size_t ids_len, const struct st
if
(
is_running
(
cont
->
state
))
{
rt_stats_params_t
params
=
{
0
};
params
.
rootpath
=
cont
->
root_path
;
params
.
state
=
cont
->
state_path
;
nret
=
runtime_resources_stats
(
cont
->
common_config
->
id
,
cont
->
runtime
,
&
params
,
&
einfo
);
if
(
nret
!=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录