提交 374e3fa0 编写于 作者: L lifeng68

refacr: rename callback module to executor

Signed-off-by: Nlifeng68 <lifeng68@huawei.com>
上级 0a9bf521
......@@ -4,7 +4,7 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} daemon_top_srcs)
add_subdirectory(runtime)
add_subdirectory(image)
add_subdirectory(plugin)
add_subdirectory(callback)
add_subdirectory(executor)
add_subdirectory(spec)
add_subdirectory(container)
add_subdirectory(connect)
......@@ -17,7 +17,7 @@ set(local_daemon_srcs
${RUNTIME_SRCS}
${IMAGE_SRCS}
${PLUGIN_SRCS}
${CALLBACK_SRCS}
${EXECUTOR_SRCS}
${SPEC_SRCS}
${MANAGER_SRCS}
${SERVER_CONNECT_SRCS}
......@@ -31,7 +31,7 @@ set(local_daemon_incs
${RUNTIME_INCS}
${IMAGE_INCS}
${PLUGIN_INCS}
${CALLBACK_INCS}
${EXECUTOR_INCS}
${SPEC_INCS}
${MANAGER_INCS}
${SERVER_CONNECT_INCS}
......
# get current directory sources files
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/ callback_top_srcs)
set(local_callback_srcs ${callback_top_srcs})
set(local_callback_incs ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(container_cb)
list(APPEND local_callback_srcs ${CONTAINER_CB_SRCS})
list(APPEND local_callback_incs ${CONTAINER_CB_INCS})
add_subdirectory(image_cb)
list(APPEND local_callback_srcs ${IMAGE_CB_SRCS})
list(APPEND local_callback_incs ${IMAGE_CB_INCS})
set(CALLBACK_SRCS
${local_callback_srcs}
PARENT_SCOPE
)
set(CALLBACK_INCS
${local_callback_incs}
PARENT_SCOPE
)
......@@ -199,7 +199,7 @@ private:
int attach_request_from_stream(const std::multimap<grpc::string_ref, grpc::string_ref> &metadata,
container_attach_request **request);
Status AttachInit(ServerContext *context, service_callback_t **cb, container_attach_request **req,
Status AttachInit(ServerContext *context, service_executor_t **cb, container_attach_request **req,
container_attach_response **res, sem_t *sem_stderr, int pipefd[]);
void add_attach_trailing_metadata(ServerContext *context, container_attach_response *response);
......
......@@ -29,8 +29,8 @@ int ImagesServiceImpl::image_list_request_from_grpc(const ListImagesRequest *gre
image_list_images_request **request)
{
size_t len = 0;
image_list_images_request *tmpreq = (image_list_images_request *)util_common_calloc_s(
sizeof(image_list_images_request));
image_list_images_request *tmpreq =
(image_list_images_request *)util_common_calloc_s(sizeof(image_list_images_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -64,8 +64,8 @@ int ImagesServiceImpl::image_list_request_from_grpc(const ListImagesRequest *gre
}
for (auto &iter : grequest->filters()) {
tmpreq->filters->values[tmpreq->filters->len] = (json_map_string_bool *)
util_common_calloc_s(sizeof(json_map_string_bool));
tmpreq->filters->values[tmpreq->filters->len] =
(json_map_string_bool *)util_common_calloc_s(sizeof(json_map_string_bool));
if (tmpreq->filters->values[tmpreq->filters->len] == nullptr) {
ERROR("Out of memory");
goto cleanup;
......@@ -135,8 +135,8 @@ int ImagesServiceImpl::image_list_response_to_grpc(image_list_images_response *r
int ImagesServiceImpl::image_remove_request_from_grpc(const DeleteImageRequest *grequest,
image_delete_image_request **request)
{
image_delete_image_request *tmpreq = (image_delete_image_request *)util_common_calloc_s(
sizeof(image_delete_image_request));
image_delete_image_request *tmpreq =
(image_delete_image_request *)util_common_calloc_s(sizeof(image_delete_image_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -151,11 +151,9 @@ int ImagesServiceImpl::image_remove_request_from_grpc(const DeleteImageRequest *
return 0;
}
int ImagesServiceImpl::image_tag_request_from_grpc(const TagImageRequest *grequest,
image_tag_image_request **request)
int ImagesServiceImpl::image_tag_request_from_grpc(const TagImageRequest *grequest, image_tag_image_request **request)
{
image_tag_image_request *tmpreq = (image_tag_image_request *)util_common_calloc_s(
sizeof(image_tag_image_request));
image_tag_image_request *tmpreq = (image_tag_image_request *)util_common_calloc_s(sizeof(image_tag_image_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -172,11 +170,9 @@ int ImagesServiceImpl::image_tag_request_from_grpc(const TagImageRequest *greque
return 0;
}
int ImagesServiceImpl::image_import_request_from_grpc(
const ImportRequest *grequest, image_import_request **request)
int ImagesServiceImpl::image_import_request_from_grpc(const ImportRequest *grequest, image_import_request **request)
{
image_import_request *tmpreq = (image_import_request *)util_common_calloc_s(
sizeof(image_import_request));
image_import_request *tmpreq = (image_import_request *)util_common_calloc_s(sizeof(image_import_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -193,11 +189,11 @@ int ImagesServiceImpl::image_import_request_from_grpc(
return 0;
}
int ImagesServiceImpl::image_load_request_from_grpc(
const LoadImageRequest *grequest, image_load_image_request **request)
int ImagesServiceImpl::image_load_request_from_grpc(const LoadImageRequest *grequest,
image_load_image_request **request)
{
image_load_image_request *tmpreq = (image_load_image_request *)util_common_calloc_s(
sizeof(image_load_image_request));
image_load_image_request *tmpreq =
(image_load_image_request *)util_common_calloc_s(sizeof(image_load_image_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -219,8 +215,7 @@ int ImagesServiceImpl::image_load_request_from_grpc(
int ImagesServiceImpl::inspect_request_from_grpc(const InspectImageRequest *grequest, image_inspect_request **request)
{
image_inspect_request *tmpreq = (image_inspect_request *)util_common_calloc_s(
sizeof(image_inspect_request));
image_inspect_request *tmpreq = (image_inspect_request *)util_common_calloc_s(sizeof(image_inspect_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -237,8 +232,7 @@ int ImagesServiceImpl::inspect_request_from_grpc(const InspectImageRequest *greq
return 0;
}
int ImagesServiceImpl::inspect_response_to_grpc(const image_inspect_response *response,
InspectImageResponse *gresponse)
int ImagesServiceImpl::inspect_response_to_grpc(const image_inspect_response *response, InspectImageResponse *gresponse)
{
if (response == nullptr) {
gresponse->set_cc(ISULAD_ERR_MEMOUT);
......@@ -261,7 +255,7 @@ Status ImagesServiceImpl::List(ServerContext *context, const ListImagesRequest *
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.list == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -294,7 +288,7 @@ Status ImagesServiceImpl::Delete(ServerContext *context, const DeleteImageReques
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.remove == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -327,7 +321,7 @@ Status ImagesServiceImpl::Tag(ServerContext *context, const TagImageRequest *req
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.tag == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -354,8 +348,7 @@ Status ImagesServiceImpl::Tag(ServerContext *context, const TagImageRequest *req
return Status::OK;
}
int ImagesServiceImpl::import_response_to_grpc(const image_import_response *response,
ImportResponse *gresponse)
int ImagesServiceImpl::import_response_to_grpc(const image_import_response *response, ImportResponse *gresponse)
{
if (response == nullptr) {
gresponse->set_cc(ISULAD_ERR_MEMOUT);
......@@ -378,7 +371,7 @@ Status ImagesServiceImpl::Import(ServerContext *context, const ImportRequest *re
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.import == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -412,7 +405,7 @@ Status ImagesServiceImpl::Load(ServerContext *context, const LoadImageRequest *r
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.load == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -444,7 +437,7 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ
InspectImageResponse *reply)
{
int ret, tret;
service_callback_t *cb = nullptr;
service_executor_t *cb = nullptr;
image_inspect_request *image_req = nullptr;
image_inspect_response *image_res = nullptr;
......@@ -453,7 +446,7 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ
return status;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == nullptr || cb->image.inspect == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -478,11 +471,9 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ
return Status::OK;
}
int ImagesServiceImpl::image_login_request_from_grpc(
const LoginRequest *grequest, image_login_request **request)
int ImagesServiceImpl::image_login_request_from_grpc(const LoginRequest *grequest, image_login_request **request)
{
image_login_request *tmpreq = (image_login_request *)util_common_calloc_s(
sizeof(image_login_request));
image_login_request *tmpreq = (image_login_request *)util_common_calloc_s(sizeof(image_login_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -505,11 +496,9 @@ int ImagesServiceImpl::image_login_request_from_grpc(
return 0;
}
int ImagesServiceImpl::image_logout_request_from_grpc(
const LogoutRequest *grequest, image_logout_request **request)
int ImagesServiceImpl::image_logout_request_from_grpc(const LogoutRequest *grequest, image_logout_request **request)
{
image_logout_request *tmpreq = (image_logout_request *)util_common_calloc_s(
sizeof(image_logout_request));
image_logout_request *tmpreq = (image_logout_request *)util_common_calloc_s(sizeof(image_logout_request));
if (tmpreq == nullptr) {
ERROR("Out of memory");
return -1;
......@@ -532,7 +521,7 @@ Status ImagesServiceImpl::Login(ServerContext *context, const LoginRequest *requ
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.login == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -566,7 +555,7 @@ Status ImagesServiceImpl::Logout(ServerContext *context, const LogoutRequest *re
if (!status.ok()) {
return status;
}
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->image.logout == nullptr) {
return Status(StatusCode::UNIMPLEMENTED, "Unimplemented callback");
}
......@@ -593,5 +582,3 @@ Status ImagesServiceImpl::Logout(ServerContext *context, const LogoutRequest *re
return Status::OK;
}
......@@ -418,7 +418,7 @@ out:
static void rest_create_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_create_response *cresponse = NULL;
container_create_request *crequest = NULL;
......@@ -427,7 +427,7 @@ static void rest_create_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.create == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -453,7 +453,7 @@ out:
static void rest_start_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_start_response *cresponse = NULL;
container_start_request *crequest = NULL;
......@@ -462,7 +462,7 @@ static void rest_start_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.start == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -488,7 +488,7 @@ out:
static void rest_wait_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_wait_request *crequest = NULL;
container_wait_response *cresponse = NULL;
......@@ -497,7 +497,7 @@ static void rest_wait_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.wait == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -551,7 +551,7 @@ out:
static void rest_stop_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_stop_request *crequest = NULL;
container_stop_response *cresponse = NULL;
......@@ -560,7 +560,7 @@ static void rest_stop_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.stop == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -613,7 +613,7 @@ out:
static void rest_restart_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_restart_request *crequest = NULL;
container_restart_response *cresponse = NULL;
......@@ -622,7 +622,7 @@ static void rest_restart_cb(evhtp_request_t *req, void *arg)
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.restart == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -670,7 +670,7 @@ out:
static void rest_version_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_version_request *crequest = NULL;
container_version_response *cresponse = NULL;
......@@ -679,7 +679,7 @@ static void rest_version_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.version == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -733,7 +733,7 @@ out:
static void rest_update_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_update_request *container_req = NULL;
container_update_response *container_res = NULL;
......@@ -742,7 +742,7 @@ static void rest_update_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.update == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -795,7 +795,7 @@ out:
static void rest_kill_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_kill_request *crequest = NULL;
container_kill_response *cresponse = NULL;
......@@ -804,7 +804,7 @@ static void rest_kill_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.kill == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -859,7 +859,7 @@ out:
static void rest_container_inspect_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_inspect_request *crequest = NULL;
container_inspect_response *cresponse = NULL;
......@@ -868,7 +868,7 @@ static void rest_container_inspect_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.inspect == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -922,7 +922,7 @@ out:
static void rest_exec_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_exec_request *crequest = NULL;
container_exec_response *cresponse = NULL;
......@@ -931,7 +931,7 @@ static void rest_exec_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || !cb->container.exec) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -984,7 +984,7 @@ out:
static void rest_remove_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_delete_request *crequest = NULL;
container_delete_response *cresponse = NULL;
......@@ -993,7 +993,7 @@ static void rest_remove_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.remove == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -1019,7 +1019,7 @@ out:
static void rest_list_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_list_request *crequest = NULL;
container_list_response *cresponse = NULL;
......@@ -1028,7 +1028,7 @@ static void rest_list_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.list == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -1104,4 +1104,3 @@ int rest_register_containers_handler(evhtp_t *htp)
}
return 0;
}
......@@ -21,8 +21,7 @@
#include "rest_images_service.h"
/* image load request check */
static int image_load_request_check(
image_load_image_request *req)
static int image_load_request_check(image_load_image_request *req)
{
if (req->type == NULL) {
DEBUG("recive NULL Request runtime");
......@@ -38,8 +37,7 @@ static int image_load_request_check(
}
/* image load request from rest */
static int image_load_request_from_rest(evhtp_request_t *req,
image_load_image_request **crequest)
static int image_load_request_from_rest(evhtp_request_t *req, image_load_image_request **crequest)
{
size_t body_len;
char *body = NULL;
......@@ -69,8 +67,7 @@ out:
}
/* evhtp send image load repsponse */
static void evhtp_send_image_load_repsponse(evhtp_request_t *req,
image_load_image_response *response, int rescode)
static void evhtp_send_image_load_repsponse(evhtp_request_t *req, image_load_image_response *response, int rescode)
{
parser_error err = NULL;
char *responsedata = NULL;
......@@ -90,8 +87,7 @@ out:
}
/* image list request from rest */
static int image_list_request_from_rest(evhtp_request_t *req,
image_list_images_request **crequest)
static int image_list_request_from_rest(evhtp_request_t *req, image_list_images_request **crequest)
{
char *body = NULL;
int ret = 0;
......@@ -117,8 +113,7 @@ out:
}
/* evhtp send image list repsponse */
static void evhtp_send_image_list_repsponse(evhtp_request_t *req,
image_list_images_response *response, int rescode)
static void evhtp_send_image_list_repsponse(evhtp_request_t *req, image_list_images_response *response, int rescode)
{
parser_error err = NULL;
char *responsedata = NULL;
......@@ -138,8 +133,7 @@ out:
}
/* image delete request check */
static int image_delete_request_check(
image_delete_image_request *req)
static int image_delete_request_check(image_delete_image_request *req)
{
int ret = 0;
......@@ -154,8 +148,7 @@ out:
}
/* image delete request from rest */
static int image_delete_request_from_rest(evhtp_request_t *req,
image_delete_image_request **crequest)
static int image_delete_request_from_rest(evhtp_request_t *req, image_delete_image_request **crequest)
{
parser_error err = NULL;
int ret = 0;
......@@ -185,8 +178,7 @@ out:
}
/* evhtp send image delete repsponse */
static void evhtp_send_image_delete_repsponse(evhtp_request_t *req,
image_delete_image_response *response, int rescode)
static void evhtp_send_image_delete_repsponse(evhtp_request_t *req, image_delete_image_response *response, int rescode)
{
parser_error err = NULL;
char *responsedata = NULL;
......@@ -219,8 +211,7 @@ static int image_inspect_request_check(void *req)
}
/* image inspect request from rest */
static int image_inspect_request_from_rest(const evhtp_request_t *req,
image_inspect_request **crequest)
static int image_inspect_request_from_rest(const evhtp_request_t *req, image_inspect_request **crequest)
{
parser_error err = NULL;
int ret = 0;
......@@ -250,8 +241,7 @@ out:
}
/* evhtp send image inspect repsponse */
static void evhtp_send_image_inspect_repsponse(evhtp_request_t *req,
image_inspect_response *response, int rescode)
static void evhtp_send_image_inspect_repsponse(evhtp_request_t *req, image_inspect_response *response, int rescode)
{
parser_error err = NULL;
struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 };
......@@ -282,7 +272,7 @@ out:
static void rest_image_load_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
image_load_image_request *crequest = NULL;
image_load_image_response *cresponse = NULL;
......@@ -291,7 +281,7 @@ static void rest_image_load_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->image.load == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -317,7 +307,7 @@ out:
static void rest_image_list_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
image_list_images_request *crequest = NULL;
image_list_images_response *cresponse = NULL;
......@@ -326,7 +316,7 @@ static void rest_image_list_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->image.list == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -352,7 +342,7 @@ out:
static void rest_image_delete_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
image_delete_image_request *crequest = NULL;
image_delete_image_response *cresponse = NULL;
......@@ -361,7 +351,7 @@ static void rest_image_delete_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->image.remove == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -387,7 +377,7 @@ out:
static void rest_image_inspect_cb(evhtp_request_t *req, void *arg)
{
int tret;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
image_inspect_request *crequest = NULL;
image_inspect_response *cresponse = NULL;
......@@ -396,7 +386,7 @@ static void rest_image_inspect_cb(evhtp_request_t *req, void *arg)
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
return;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->image.inspect == NULL) {
ERROR("Unimplemented callback");
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
......@@ -423,17 +413,17 @@ int rest_register_images_handler(evhtp_t *htp)
{
if (evhtp_set_cb(htp, ImagesServiceLoad, rest_image_load_cb, NULL) == NULL) {
ERROR("Failed to register image load callback");
return -1;
return -1;
}
if (evhtp_set_cb(htp, ImagesServiceList, rest_image_list_cb, NULL) == NULL) {
ERROR("Failed to register image list callback");
return -1;
return -1;
}
if (evhtp_set_cb(htp, ImagesServiceDelete, rest_image_delete_cb, NULL) == NULL) {
ERROR("Failed to register image list callback");
return -1;
return -1;
}
if (evhtp_set_cb(htp, ImagesServiceInspect, rest_image_inspect_cb, NULL) == NULL) {
......@@ -443,4 +433,3 @@ int rest_register_images_handler(evhtp_t *htp)
return 0;
}
......@@ -513,7 +513,7 @@ void *health_check_run(void *arg)
struct io_write_wrapper Stdoutctx = { 0 };
struct io_write_wrapper Stderrctx = { 0 };
container_t *cont = NULL;
service_callback_t *cb = NULL;
service_executor_t *cb = NULL;
container_exec_request *container_req = NULL;
container_exec_response *container_res = NULL;
defs_health_log_element *result = NULL;
......@@ -540,7 +540,7 @@ void *health_check_run(void *arg)
goto out;
}
cb = get_service_callback();
cb = get_service_executor();
if (cb == NULL || cb->container.exec == NULL) {
ERROR("Failed to get service callback function");
goto out;
......
......@@ -42,7 +42,7 @@ std::string Constants::RESOLV_CONF_PATH { "/etc/resolv.conf" };
} // namespace CRIRuntimeService
CRIRuntimeServiceImpl::CRIRuntimeServiceImpl()
{
m_cb = get_service_callback();
m_cb = get_service_executor();
if (m_cb == nullptr) {
ERROR("Get callback failed");
}
......@@ -112,7 +112,8 @@ void CRIRuntimeServiceImpl::UpdateRuntimeConfig(const runtime::v1alpha2::Runtime
INFO("iSulad cri received runtime config: %s", config.network_config().pod_cidr().c_str());
if (m_pluginManager != nullptr && config.has_network_config() && !(config.network_config().pod_cidr().empty())) {
std::map<std::string, std::string> events;
events[CRIHelpers::Constants::NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR] = config.network_config().pod_cidr();
events[CRIHelpers::Constants::NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR] =
config.network_config().pod_cidr();
m_pluginManager->Event(CRIHelpers::Constants::NET_PLUGIN_EVENT_POD_CIDR_CHANGE, events);
}
return;
......@@ -184,4 +185,3 @@ cleanup:
free_container_inspect(inspect_data);
return result;
}
......@@ -229,10 +229,10 @@ private:
host_config *hostconfig, Errors &error);
int PackCreateContainerHostConfigDevices(const runtime::v1alpha2::ContainerConfig &containerConfig,
host_config *hostconfig, Errors &error);
container_config *
GenerateCreateContainerCustomConfig(const std::string &realPodSandboxID,
const runtime::v1alpha2::ContainerConfig &containerConfig,
const runtime::v1alpha2::PodSandboxConfig &podSandboxConfig, Errors &error);
container_config *GenerateCreateContainerCustomConfig(const std::string &realPodSandboxID,
const runtime::v1alpha2::ContainerConfig &containerConfig,
const runtime::v1alpha2::PodSandboxConfig &podSandboxConfig,
Errors &error);
int PackContainerImageToStatus(container_inspect *inspect,
std::unique_ptr<runtime::v1alpha2::ContainerStatus> &contStatus, Errors &error);
void UpdateBaseStatusFromInspect(container_inspect *inspect, int64_t &createdAt, int64_t &startedAt,
......@@ -252,7 +252,8 @@ private:
std::string CreateSandboxContainer(const runtime::v1alpha2::PodSandboxConfig &config, const std::string &image,
std::string &jsonCheckpoint, const std::string &runtimeHandler, Errors &error);
container_create_request *GenerateSandboxCreateContainerRequest(const runtime::v1alpha2::PodSandboxConfig &config,
const std::string &image, std::string &jsonCheckpoint,
const std::string &image,
std::string &jsonCheckpoint,
const std::string &runtimeHandler, Errors &error);
container_create_request *PackCreateContainerRequest(const runtime::v1alpha2::PodSandboxConfig &config,
const std::string &image, host_config *hostconfig,
......@@ -269,13 +270,12 @@ private:
std::map<std::string, std::string> &stdAnnos, Errors &error);
int RemoveAllContainersInSandbox(const std::string &realSandboxID, std::vector<std::string> &errors);
int DoRemovePodSandbox(const std::string &realSandboxID, std::vector<std::string> &errors);
void MergeSecurityContextToHostConfig(const runtime::v1alpha2::PodSandboxConfig &c,
host_config *hc, Errors &error);
void MergeSecurityContextToHostConfig(const runtime::v1alpha2::PodSandboxConfig &c, host_config *hc, Errors &error);
int PackContainerStatsFilter(const runtime::v1alpha2::ContainerStatsFilter *filter,
container_stats_request *request, Errors &error);
private:
service_callback_t *m_cb { nullptr };
service_executor_t *m_cb { nullptr };
std::shared_ptr<Network::PluginManager> m_pluginManager { nullptr };
......
......@@ -13,12 +13,10 @@
* Description: provide container attach functions
******************************************************************************/
#include "attach_serve.h"
#include "utils.h"
int AttachServe::Execute(struct lws *wsi, const std::string &token,
int read_pipe_fd)
int AttachServe::Execute(struct lws *wsi, const std::string &token, int read_pipe_fd)
{
RequestCache *cache = RequestCache::GetInstance();
bool found = false;
......@@ -36,7 +34,7 @@ int AttachServe::Execute(struct lws *wsi, const std::string &token,
container_attach_request *container_req = nullptr;
container_attach_response *container_res = nullptr;
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->container.attach == nullptr) {
return -1;
}
......@@ -51,8 +49,8 @@ int AttachServe::Execute(struct lws *wsi, const std::string &token,
stringWriter.write_func = WsWriteStdoutToClient;
stringWriter.close_func = closeWsConnect;
container_req->attach_stderr = false;
int ret = cb->container.attach(container_req, &container_res,
container_req->attach_stdin ? read_pipe_fd : -1, &stringWriter, nullptr);
int ret = cb->container.attach(container_req, &container_res, container_req->attach_stdin ? read_pipe_fd : -1,
&stringWriter, nullptr);
free_container_attach_request(container_req);
free_container_attach_response(container_res);
......@@ -67,8 +65,7 @@ int AttachServe::Execute(struct lws *wsi, const std::string &token,
return ret;
}
int AttachServe::RequestFromCri(const runtime::v1alpha2::AttachRequest *grequest,
container_attach_request **request)
int AttachServe::RequestFromCri(const runtime::v1alpha2::AttachRequest *grequest, container_attach_request **request)
{
container_attach_request *tmpreq = nullptr;
......@@ -89,5 +86,3 @@ int AttachServe::RequestFromCri(const runtime::v1alpha2::AttachRequest *grequest
return 0;
}
......@@ -35,7 +35,7 @@ int ExecServe::Execute(struct lws *wsi, const std::string &token, int read_pipe_
container_exec_request *container_req = nullptr;
container_exec_response *container_res = nullptr;
service_callback_t *cb = get_service_callback();
service_executor_t *cb = get_service_executor();
if (cb == nullptr || cb->container.exec == nullptr) {
return -1;
}
......
# get current directory sources files
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/ executor_top_srcs)
set(local_executor_srcs ${executor_top_srcs})
set(local_executor_incs ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(container_cb)
list(APPEND local_executor_srcs ${CONTAINER_CB_SRCS})
list(APPEND local_executor_incs ${CONTAINER_CB_INCS})
add_subdirectory(image_cb)
list(APPEND local_executor_srcs ${IMAGE_CB_SRCS})
list(APPEND local_executor_incs ${IMAGE_CB_INCS})
set(EXECUTOR_SRCS
${local_executor_srcs}
PARENT_SCOPE
)
set(EXECUTOR_INCS
${local_executor_incs}
PARENT_SCOPE
)
......@@ -17,19 +17,18 @@
#include "image_cb.h"
#include "execution.h"
service_callback_t g_isulad_servicecallback;
service_executor_t g_isulad_service_executor;
/* service callback */
int service_callback_init(void)
{
container_callback_init(&g_isulad_servicecallback.container);
image_callback_init(&g_isulad_servicecallback.image);
container_callback_init(&g_isulad_service_executor.container);
image_callback_init(&g_isulad_service_executor.image);
return 0;
}
/* get service callback */
service_callback_t *get_service_callback(void)
service_executor_t *get_service_executor(void)
{
return &g_isulad_servicecallback;
return &g_isulad_service_executor;
}
......@@ -177,11 +177,11 @@ typedef struct {
service_container_callback_t container;
service_image_callback_t image;
service_health_callback_t health;
} service_callback_t;
} service_executor_t;
int service_callback_init(void);
service_callback_t *get_service_callback(void);
service_executor_t *get_service_executor(void);
#ifdef __cplusplus
}
......
......@@ -295,7 +295,8 @@ err_out:
return NULL;
}
static int exec_container(container_t *cont, const char *runtime, char * const console_fifos[], defs_process_user *puser,
static int exec_container(container_t *cont, const char *runtime, char * const console_fifos[],
defs_process_user *puser,
const container_exec_request *request, int *exit_code)
{
int ret = 0;
......
......@@ -26,7 +26,7 @@ add_executable(${EXE}
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_verify.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/map/map.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/map/rb_tree.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/callback/container_cb/execution_extend.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/executor/container_cb/execution_extend.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/runtime_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/containers_store_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/collector_mock.cc
......@@ -63,11 +63,11 @@ target_include_directories(${EXE} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/container/health_check
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/container/container_gc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/image/oci
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/callback
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/executor
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/spec/
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/events
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/events_sender
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/callback/container_cb
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/executor/container_cb
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../conf
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册