Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
b996e1e6
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,发现更多精彩内容 >>
提交
b996e1e6
编写于
6月 11, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
6月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
!445 event: fix event msg struct size and add retry send
Merge pull request !445 from lifeng_isula/master
上级
3e619894
4e4a91f7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
37 addition
and
47 deletion
+37
-47
src/services/execution/events/collector.c
src/services/execution/events/collector.c
+32
-38
src/services/execution/manager/monitord.h
src/services/execution/manager/monitord.h
+5
-9
未找到文件。
src/services/execution/events/collector.c
浏览文件 @
b996e1e6
...
...
@@ -129,10 +129,10 @@ static container_events_type_t lcrsta2Evetype(int value)
}
static
const
char
*
const
g_isulad_event_strtype
[]
=
{
"exit"
,
"die"
,
"starting"
,
"running"
,
"stopping"
,
"aborting"
,
"freezing"
,
"frozen"
,
"thawed
"
,
"
oom"
,
"create"
,
"start"
,
"restart"
,
"stop"
,
"exec_create"
,
"exec_start"
,
"exec_die"
,
"attach
"
,
"
kill"
,
"top"
,
"reanme"
,
"archive-path"
,
"extract-to-dir"
,
"update"
,
"pause"
,
"unpause"
,
"export
"
,
"
resize"
,
"paused1"
,
"exit"
,
"die"
,
"starting"
,
"running"
,
"stopping"
,
"aborting"
,
"freezing"
,
"frozen
"
,
"
thawed"
,
"oom"
,
"create"
,
"start"
,
"restart"
,
"stop"
,
"exec_create"
,
"exec_start
"
,
"
exec_die"
,
"attach"
,
"kill"
,
"top"
,
"reanme"
,
"archive-path"
,
"extract-to-dir"
,
"update
"
,
"
pause"
,
"unpause"
,
"export"
,
"resize"
,
"paused1"
,
};
/* isulad event sta2str */
...
...
@@ -145,9 +145,7 @@ static const char *isulad_event_sta2str(container_events_type_t sta)
return
g_isulad_event_strtype
[
sta
];
}
static
const
char
*
const
g_isulad_image_event_strtype
[]
=
{
"load"
,
"remove"
,
"pull"
,
"login"
,
"logout"
};
static
const
char
*
const
g_isulad_image_event_strtype
[]
=
{
"load"
,
"remove"
,
"pull"
,
"login"
,
"logout"
};
static
const
char
*
isulad_image_event_sta2str
(
image_events_type_t
sta
)
{
...
...
@@ -182,7 +180,7 @@ static int supplement_operator_for_container_msg(const struct monitord_msg *msg,
{
#define CONTAINER_OPERATOR_MAX_LEN 300
int
nret
=
0
;
char
opt
[
CONTAINER_OPERATOR_MAX_LEN
]
=
{
0x00
};
char
opt
[
CONTAINER_OPERATOR_MAX_LEN
]
=
{
0x00
};
if
(
strlen
(
msg
->
args
)
!=
0
)
{
nret
=
snprintf
(
opt
,
sizeof
(
opt
),
"container %s: %s"
,
isulad_event_sta2str
(
msg
->
value
),
msg
->
args
);
...
...
@@ -203,7 +201,7 @@ static int supplement_pid_for_container_msg(const container_t *cont, const struc
struct
isulad_events_format
*
format_msg
)
{
int
nret
=
0
;
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
if
(
cont
->
state
==
NULL
||
cont
->
state
->
state
==
NULL
||
cont
->
state
->
state
->
pid
<=
0
)
{
return
0
;
...
...
@@ -227,7 +225,7 @@ static int supplement_exitcode_for_container_msg(const container_t *cont, const
{
int
nret
=
0
;
int
exit_code
=
0
;
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
if
(
format_msg
->
exit_status
!=
0
)
{
exit_code
=
format_msg
->
exit_status
;
...
...
@@ -256,7 +254,7 @@ static int supplement_image_for_container_msg(const container_t *cont, const str
struct
isulad_events_format
*
format_msg
)
{
int
nret
=
0
;
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
if
(
cont
->
common_config
==
NULL
||
cont
->
common_config
->
image
==
NULL
)
{
return
0
;
...
...
@@ -279,7 +277,7 @@ static int supplement_name_for_container_msg(const container_t *cont, const stru
struct
isulad_events_format
*
format_msg
)
{
int
nret
=
0
;
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
if
(
cont
->
common_config
==
NULL
||
cont
->
common_config
->
name
==
NULL
)
{
return
0
;
...
...
@@ -303,14 +301,13 @@ static int supplement_labels_for_container_msg(const container_t *cont, const st
{
size_t
i
;
if
(
cont
->
common_config
==
NULL
||
cont
->
common_config
->
config
->
labels
==
NULL
||
if
(
cont
->
common_config
==
NULL
||
cont
->
common_config
->
config
->
labels
==
NULL
||
cont
->
common_config
->
config
->
labels
->
len
==
0
)
{
return
0
;
}
for
(
i
=
0
;
i
<
cont
->
common_config
->
config
->
labels
->
len
;
i
++
)
{
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
char
info
[
EXTRA_ANNOTATION_MAX
]
=
{
0x00
};
int
nret
=
snprintf
(
info
,
sizeof
(
info
),
"%s=%s"
,
cont
->
common_config
->
config
->
labels
->
keys
[
i
],
cont
->
common_config
->
config
->
labels
->
values
[
i
]);
if
(
nret
<
0
||
nret
>=
sizeof
(
info
))
{
...
...
@@ -329,7 +326,6 @@ static int supplement_labels_for_container_msg(const container_t *cont, const st
static
int
supplement_annotations_for_container_msg
(
const
container_t
*
cont
,
const
struct
monitord_msg
*
msg
,
struct
isulad_events_format
*
format_msg
)
{
if
(
supplement_pid_for_container_msg
(
cont
,
msg
,
format_msg
)
!=
0
)
{
ERROR
(
"Failed to supplement pid info"
);
return
-
1
;
...
...
@@ -406,7 +402,7 @@ static int supplement_msg_for_image(struct monitord_msg *msg, struct isulad_even
#define IMAGE_OPERATOR_MAX_LEN 50
int
ret
=
0
;
int
nret
=
0
;
char
opt
[
IMAGE_OPERATOR_MAX_LEN
]
=
{
0x00
};
char
opt
[
IMAGE_OPERATOR_MAX_LEN
]
=
{
0x00
};
format_msg
->
id
=
util_strdup_s
(
msg
->
name
);
...
...
@@ -490,11 +486,12 @@ static void isulad_monitor_fifo_send(const struct monitord_msg *msg, const char
goto
out
;
}
ret
=
write
(
fd
,
msg
,
sizeof
(
struct
monitord_msg
));
if
(
ret
<
0
||
(
size_t
)
ret
!=
sizeof
(
struct
monitord_msg
))
{
ERROR
(
"Failed to write to monitor fifo
\"
%s
\"
: %s."
,
fifo_path
,
strerror
(
errno
));
goto
out
;
do
{
ret
=
util_write_nointr
(
fd
,
msg
,
sizeof
(
struct
monitord_msg
));
if
(
ret
!=
sizeof
(
struct
monitord_msg
))
{
usleep_nointerupt
(
1000
)
;
}
}
while
(
ret
!=
sizeof
(
struct
monitord_msg
));
out:
free
(
fifo_path
);
...
...
@@ -509,14 +506,13 @@ int isulad_monitor_send_container_event(const char *name, runtime_state_t state,
{
int
ret
=
0
;
char
*
statedir
=
NULL
;
struct
monitord_msg
msg
=
{
.
type
=
MONITORD_MSG_STATE
,
struct
monitord_msg
msg
=
{
.
type
=
MONITORD_MSG_STATE
,
.
event_type
=
CONTAINER_EVENT
,
.
value
=
state
,
.
pid
=
-
1
,
.
exit_code
=
-
1
,
.
args
=
{
0x00
},
.
extra_annations
=
{
0x00
}
.
args
=
{
0x00
},
.
extra_annations
=
{
0x00
}
};
if
(
name
==
NULL
)
{
...
...
@@ -565,12 +561,11 @@ int isulad_monitor_send_image_event(const char *name, image_state_t state)
int
ret
=
0
;
char
*
statedir
=
NULL
;
struct
monitord_msg
msg
=
{
.
type
=
MONITORD_MSG_STATE
,
struct
monitord_msg
msg
=
{
.
type
=
MONITORD_MSG_STATE
,
.
event_type
=
IMAGE_EVENT
,
.
value
=
state
,
.
args
=
{
0x00
},
.
extra_annations
=
{
0x00
}
.
args
=
{
0x00
},
.
extra_annations
=
{
0x00
}
};
if
(
name
==
NULL
)
{
...
...
@@ -1090,7 +1085,6 @@ struct isulad_events_format *dup_event(const struct isulad_events_format *event)
return
out
;
}
/* add monitor client */
int
add_monitor_client
(
char
*
name
,
const
types_timestamp_t
*
since
,
const
types_timestamp_t
*
until
,
const
stream_func_wrapper
*
stream
)
...
...
src/services/execution/manager/monitord.h
浏览文件 @
b996e1e6
...
...
@@ -19,20 +19,17 @@
#include <limits.h>
#include "engine.h"
#include "libisulad.h"
#include "utils.h"
#define ARGS_MAX 255
/* # args chars in a monitord msg */
#define EXTRA_ANNOTATION_MAX
1024
/* # annotation chars in a monitord msg */
#define EXTRA_ANNOTATION_MAX
255
/* # annotation chars in a monitord msg */
typedef
enum
{
MONITORD_MSG_STATE
,
MONITORD_MSG_PRIORITY
,
MONITORD_MSG_EXIT_CODE
}
msg_type_t
;
typedef
enum
{
MONITORD_MSG_STATE
,
MONITORD_MSG_PRIORITY
,
MONITORD_MSG_EXIT_CODE
}
msg_type_t
;
struct
monitord_msg
{
msg_type_t
type
;
msg_event_type_t
event_type
;
char
name
[
NAME_MAX
+
1
];
char
name
[
CONTAINER_ID_MAX_LEN
+
1
];
char
args
[
ARGS_MAX
];
char
extra_annations
[
EXTRA_ANNOTATION_MAX
];
int
value
;
...
...
@@ -54,4 +51,3 @@ int read_monitord_message_timeout(int fd, struct monitord_msg *msg, int timeout)
int
new_monitord
(
struct
monitord_sync_data
*
msync
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录