70 lines
2.2 KiB
Diff
70 lines
2.2 KiB
Diff
From 4abeb19ab3064725d1c84e80a33b16aca5f9d8ba Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <zhongtao17@huawei.com>
|
|
Date: Wed, 10 May 2023 21:04:25 +0800
|
|
Subject: [PATCH 63/79] add try_generate_exec_id func for health check
|
|
|
|
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
|
---
|
|
.../modules/runtime/isula/isula_rt_ops.c | 31 +++++++++++++++++--
|
|
1 file changed, 29 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
|
index ceaf464e..85a2fbc8 100644
|
|
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
|
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
|
@@ -1082,6 +1082,28 @@ static bool fg_exec(const rt_exec_params_t *params)
|
|
return false;
|
|
}
|
|
|
|
+static char *try_generate_exec_id()
|
|
+{
|
|
+ char *id = NULL;
|
|
+
|
|
+ id = util_common_calloc_s(sizeof(char) * (CONTAINER_EXEC_ID_MAX_LEN + 1));
|
|
+ if (id == NULL) {
|
|
+ ERROR("Out of memory");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (util_generate_random_str(id, (size_t)CONTAINER_EXEC_ID_MAX_LEN) != 0) {
|
|
+ ERROR("Generate id failed");
|
|
+ goto err_out;
|
|
+ }
|
|
+
|
|
+ return id;
|
|
+
|
|
+err_out:
|
|
+ free(id);
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *params, int *exit_code)
|
|
{
|
|
char *exec_id = NULL;
|
|
@@ -1097,7 +1119,7 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
|
|
shim_client_process_state p = { 0 };
|
|
char *timeout = NULL;
|
|
|
|
- if (id == NULL || runtime == NULL || params == NULL || exit_code == NULL || params->suffix == NULL) {
|
|
+ if (id == NULL || runtime == NULL || params == NULL || exit_code == NULL) {
|
|
ERROR("nullptr arguments not allowed");
|
|
return -1;
|
|
}
|
|
@@ -1110,7 +1132,12 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
|
|
return -1;
|
|
}
|
|
|
|
- exec_id = util_strdup_s(params->suffix);
|
|
+ if (params->suffix != NULL) {
|
|
+ exec_id = util_strdup_s(params->suffix);
|
|
+ } else {
|
|
+ // in the health check scenario, suffix is empty
|
|
+ exec_id = try_generate_exec_id();
|
|
+ }
|
|
if (exec_id == NULL) {
|
|
ERROR("Out of memory or generate exec id failed");
|
|
return -1;
|
|
--
|
|
2.25.1
|
|
|