!16 iSulad: internal change at 3.6
Merge pull request !16 from lifeng_isula/3.6
This commit is contained in:
commit
61b7a0fae6
@ -69,6 +69,14 @@ find_library(CURL_LIBRARY curl
|
||||
HINTS ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS})
|
||||
_CHECK(CURL_LIBRARY "CURL_LIBRARY-NOTFOUND" "libcurl.so")
|
||||
|
||||
pkg_check_modules(PC_SELINUX "libselinux>=2.0")
|
||||
find_path(SELINUX_INCLUDE_DIR "selinux/selinux.h"
|
||||
HINTS ${PC_SELINUX_INCLUDEDIR} ${PC_SELINUX_INCLUDE_DIRS})
|
||||
_CHECK(SELINUX_INCLUDE_DIR "SELINUX_INCLUDE_DIR-NOTFOUND" "selinux/selinux.h")
|
||||
find_library(SELINUX_LIBRARY selinux
|
||||
HINTS ${PC_SELINUX_LIBDIR} ${PC_SELINUX_LIBRARY_DIRS})
|
||||
_CHECK(SELINUX_LIBRARY "SELINUX_LIBRARY-NOTFOUND" "libselinux.so")
|
||||
|
||||
if (OPENSSL_VERIFY)
|
||||
find_path(OPENSSL_INCLUDE_DIR openssl/x509.h)
|
||||
_CHECK(OPENSSL_INCLUDE_DIR "OPENSSL_INCLUDE_DIR-NOTFOUND" "openssl/x509.h")
|
||||
|
||||
@ -33,7 +33,7 @@ endif()
|
||||
|
||||
option(VERSION "set isulad version" ON)
|
||||
if (VERSION STREQUAL "ON")
|
||||
set(ISULAD_VERSION "1.1.11")
|
||||
set(ISULAD_VERSION "1.1.12")
|
||||
endif()
|
||||
|
||||
option(DEBUG "set isulad gcc option" ON)
|
||||
|
||||
15
iSulad.spec
15
iSulad.spec
@ -1,5 +1,5 @@
|
||||
%global _version 1.1.11
|
||||
%global _release 20200204.221506.git50cfadfa
|
||||
%global _version 1.1.12
|
||||
%global _release 20200306.143730.gitb83d1ed8
|
||||
%global is_systemd 1
|
||||
%global debug_package %{nil}
|
||||
|
||||
@ -30,18 +30,18 @@ Requires(preun): initscripts
|
||||
%endif
|
||||
|
||||
BuildRequires: cmake gcc-c++ lxc lxc-devel lcr yajl yajl-devel clibcni-devel
|
||||
BuildRequires: grpc grpc-devel protobuf-devel
|
||||
BuildRequires: grpc grpc-plugins grpc-devel protobuf-devel
|
||||
BuildRequires: libcurl libcurl-devel sqlite-devel
|
||||
BuildRequires: http-parser-devel libevhtp-devel libevent-devel
|
||||
BuildRequires: libseccomp-devel libcap-devel libwebsockets libwebsockets-devel
|
||||
BuildRequires: http-parser-devel
|
||||
BuildRequires: libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel
|
||||
BuildRequires: systemd-devel git python3
|
||||
|
||||
Requires: iSulad-img lcr lxc clibcni
|
||||
Requires: grpc protobuf yajl
|
||||
Requires: libcurl
|
||||
Requires: sqlite http-parser libseccomp
|
||||
Requires: libcap libwebsockets
|
||||
Requires: libevhtp libevent systemd
|
||||
Requires: libcap libselinux libwebsockets
|
||||
Requires: systemd
|
||||
|
||||
%description
|
||||
This is a umbrella project for gRPC-services based Lightweight Container
|
||||
@ -68,6 +68,7 @@ install -m 0640 ./conf/isulad.pc %{buildroot}/%{_libdir}/pkgconfig/
|
||||
|
||||
install -d $RPM_BUILD_ROOT/%{_bindir}
|
||||
install -m 0755 ./src/isula %{buildroot}/%{_bindir}/isula
|
||||
install -m 0755 ./src/isulad-shim %{buildroot}/%{_bindir}/isulad-shim
|
||||
install -m 0755 ./src/isulad %{buildroot}/%{_bindir}/isulad
|
||||
|
||||
install -d $RPM_BUILD_ROOT/%{_includedir}/isulad
|
||||
|
||||
@ -13,7 +13,6 @@ list(REMOVE_DUPLICATES JSON_FILES)
|
||||
set(CHECKED_INCLUDE_DIRS
|
||||
${STD_HEADER_CTYPE}
|
||||
${STD_HEADER_SYS_PARAM}
|
||||
${LIBSECUREC_INCLUDE_DIR}
|
||||
${LIBYAJL_INCLUDE_DIR}
|
||||
${HTTP_PARSER_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
@ -123,7 +122,7 @@ target_include_directories(libisula PUBLIC
|
||||
|
||||
# set libisula FLAGS
|
||||
set_target_properties(libisula PROPERTIES PREFIX "")
|
||||
target_link_libraries(libisula ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY})
|
||||
target_link_libraries(libisula ${LIBYAJL_LIBRARY} ${SELINUX_LIBRARY})
|
||||
|
||||
if (GRPC_CONNECTOR)
|
||||
target_link_libraries(libisula -Wl,--as-needed -lstdc++ -lcrypto)
|
||||
@ -143,6 +142,18 @@ target_include_directories(isula PUBLIC ${ISULA_INCS} ${SHARED_INCS})
|
||||
target_link_libraries(isula libisula -lpthread)
|
||||
# ------ build isula finish -------
|
||||
|
||||
# ------ build isulad-shim -------
|
||||
add_executable(isulad-shim
|
||||
${ISULAD_SHIM_SRCS}
|
||||
${CMAKE_BINARY_DIR}/json/shim_client_process_state.c
|
||||
${CMAKE_BINARY_DIR}/json/json_common.c
|
||||
${commonjsonsrcs}
|
||||
)
|
||||
target_include_directories(isulad-shim PUBLIC ${ISULAD_SHIM_INCS} ${SHARED_INCS})
|
||||
target_link_libraries(isulad-shim ${LIBYAJL_LIBRARY} -lpthread)
|
||||
|
||||
# ------ build isula-shim finish -------
|
||||
|
||||
# ------ build isulad -------
|
||||
add_subdirectory(services)
|
||||
add_subdirectory(image)
|
||||
@ -201,7 +212,7 @@ target_include_directories(isulad PUBLIC
|
||||
${WEBSOCKET_SERVICE_INCS}
|
||||
)
|
||||
|
||||
target_link_libraries(isulad ${LIBYAJL_LIBRARY} ${LIBSECUREC_LIBRARY} ${SYSTEMD_LIBRARY})
|
||||
target_link_libraries(isulad ${LIBYAJL_LIBRARY} ${SYSTEMD_LIBRARY} ${SELINUX_LIBRARY})
|
||||
target_link_libraries(isulad -ldl ${ZLIB_LIBRARY} -lpthread libhttpclient)
|
||||
if (ENABLE_EMBEDDED_IMAGE)
|
||||
target_link_libraries(isulad ${SQLITE3_LIBRARY})
|
||||
@ -237,5 +248,7 @@ install(TARGETS libisula
|
||||
LIBRARY DESTINATION ${LIB_INSTALL_DIR_DEFAULT} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
|
||||
install(TARGETS isula
|
||||
RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
|
||||
install(TARGETS isulad-shim
|
||||
RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
|
||||
install(TARGETS isulad
|
||||
RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
|
||||
|
||||
@ -84,11 +84,10 @@ message Container_info {
|
||||
}
|
||||
|
||||
message Event {
|
||||
string id = 1;
|
||||
EventType type = 2;
|
||||
int32 pid = 3;
|
||||
uint32 exit_status = 4;
|
||||
google.protobuf.Timestamp timestamp = 5;
|
||||
google.protobuf.Timestamp timestamp = 1;
|
||||
string opt = 2;
|
||||
string id = 3;
|
||||
map<string, string> annotations= 4;
|
||||
}
|
||||
|
||||
service ContainerService {
|
||||
|
||||
@ -8,3 +8,7 @@ set(ISULA_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_ISULA_INCS} PARENT_SCOPE)
|
||||
add_subdirectory(isulad)
|
||||
set(ISULAD_SRCS ${comm_srcs} ${CMD_ISULAD_SRCS} PARENT_SCOPE)
|
||||
set(ISULAD_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_ISULAD_INCS} PARENT_SCOPE)
|
||||
|
||||
add_subdirectory(isulad-shim)
|
||||
set(ISULAD_SHIM_SRCS ${CMD_ISULAD_SHIM_SRCS} PARENT_SCOPE)
|
||||
set(ISULAD_SHIM_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${CMD_ISULAD_SHIM_INCS} PARENT_SCOPE)
|
||||
|
||||
@ -737,6 +737,23 @@ int command_convert_memswapbytes(command_option_t *option, const char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int command_convert_swappiness(command_option_t *option, const char *arg)
|
||||
{
|
||||
if (option == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(arg, "-1") == 0) {
|
||||
*(int64_t *)(option->data) = -1;
|
||||
return 0;
|
||||
}
|
||||
if (util_parse_byte_size_string(arg, option->data) || (*(int64_t *)(option->data)) < 0 ||
|
||||
(*(int64_t *)(option->data)) > 100) {
|
||||
COMMAND_ERROR("Invalid value \"%s\" for flag --%s. Valid memory swappiness range is 0-100", arg, option->large);
|
||||
return EINVALIDARGS;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t ulimit_array_len(host_config_ulimits_element **default_ulimit)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
@ -21,6 +21,10 @@
|
||||
|
||||
#include "host_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef COMMANDER_MAX_OPTIONS
|
||||
#define COMMANDER_MAX_OPTIONS 64
|
||||
#endif
|
||||
@ -112,5 +116,11 @@ int check_default_ulimit_type(const char *type);
|
||||
|
||||
void free_default_ulimit(host_config_ulimits_element **default_ulimit);
|
||||
|
||||
int command_convert_swappiness(command_option_t *option, const char *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMMANDER_H */
|
||||
|
||||
|
||||
@ -135,6 +135,9 @@ int client_arguments_init(struct client_arguments *args)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// default swappiness should be set to -1
|
||||
args->cr.swappiness = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,10 @@
|
||||
#include "json_common.h"
|
||||
#include "isula_connect.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* max arguments can be specify in client */
|
||||
#define MAX_CLIENT_ARGS 1000
|
||||
|
||||
@ -39,6 +43,12 @@ struct custom_configs {
|
||||
/* environment variables file */
|
||||
char **env_file;
|
||||
|
||||
/* label */
|
||||
char **label;
|
||||
|
||||
/* label file */
|
||||
char **label_file;
|
||||
|
||||
/* hugepage limits */
|
||||
char **hugepage_limits;
|
||||
|
||||
@ -202,6 +212,7 @@ struct args_cgroup_resources {
|
||||
int64_t memory_swap;
|
||||
int64_t memory_reservation;
|
||||
int64_t kernel_memory_limit;
|
||||
int64_t swappiness;
|
||||
};
|
||||
|
||||
struct client_arguments {
|
||||
@ -350,5 +361,9 @@ extern void client_print_error(uint32_t cc, uint32_t server_errono, const char *
|
||||
|
||||
extern client_connect_config_t get_connect_config(const struct client_arguments *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ISULA_ARGUMENTS_H */
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* Description: provide container create functions
|
||||
******************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -37,7 +38,7 @@ const char g_cmd_create_desc[] = "Create a new container";
|
||||
const char g_cmd_create_usage[] = "create [OPTIONS] --external-rootfs=PATH|IMAGE [COMMAND] [ARG...]";
|
||||
|
||||
struct client_arguments g_cmd_create_args = {
|
||||
.runtime = "lcr",
|
||||
.runtime = "",
|
||||
.restart = "no",
|
||||
.log_file_size = "1MB",
|
||||
.log_file_rotate = 7,
|
||||
@ -172,6 +173,8 @@ static int request_pack_host_config_cgroup(const struct client_arguments *args,
|
||||
/* kernel memory limit */
|
||||
hostconfig->cr->kernel_memory = args->cr.kernel_memory_limit;
|
||||
|
||||
hostconfig->cr->swappiness = args->cr.swappiness;
|
||||
|
||||
request_pack_host_config_limit(args, hostconfig);
|
||||
|
||||
return 0;
|
||||
@ -414,6 +417,149 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool validate_label(const char *label)
|
||||
{
|
||||
bool ret = true;
|
||||
char **arr = util_string_split_n(label, '=', 2);
|
||||
if (arr == NULL) {
|
||||
ERROR("Failed to split label string");
|
||||
ret = false;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strlen(arr[0]) == 0) {
|
||||
ERROR("Invalid label: %s, empty name", label);
|
||||
ret = false;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
util_free_array(arr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int request_pack_custom_label(struct client_arguments *args, isula_container_config_t *conf)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t i;
|
||||
|
||||
if (args->custom_conf.label == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < util_array_len((const char **)(args->custom_conf.label)); i++) {
|
||||
if (!validate_label(args->custom_conf.label[i])) {
|
||||
COMMAND_ERROR("Invalid label '%s': empty name", args->custom_conf.label[i]);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (util_array_append(&conf->label, args->custom_conf.label[i]) != 0) {
|
||||
COMMAND_ERROR("Failed to append custom config label list");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
util_free_array(args->custom_conf.label);
|
||||
args->custom_conf.label = conf->label; /* make sure args->custom_conf.label point to valid memory. */
|
||||
conf->label_len = util_array_len((const char **)(conf->label));
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_label_from_file(const char *path, size_t file_size, isula_container_config_t *conf)
|
||||
{
|
||||
int ret = 0;
|
||||
FILE *fp = NULL;
|
||||
char *buf = NULL;
|
||||
size_t len;
|
||||
ssize_t num;
|
||||
|
||||
if (file_size == 0) {
|
||||
return 0;
|
||||
}
|
||||
fp = fopen(path, "re");
|
||||
if (fp == NULL) {
|
||||
ERROR("Failed to open '%s'", path);
|
||||
return -1;
|
||||
}
|
||||
__fsetlocking(fp, FSETLOCKING_BYCALLER);
|
||||
num = getline(&buf, &len, fp);
|
||||
while (num != -1) {
|
||||
size_t len = strlen(buf);
|
||||
if (len == 1) {
|
||||
num = getline(&buf, &len, fp);
|
||||
continue;
|
||||
}
|
||||
buf[len - 1] = '\0';
|
||||
if (!validate_label(buf)) {
|
||||
COMMAND_ERROR("Invalid label '%s': empty name", buf);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (util_array_append(&conf->label, buf) != 0) {
|
||||
ERROR("Failed to append label");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
num = getline(&buf, &len, fp);
|
||||
}
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
fclose(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int append_labels_to_conf(const char *label_file, isula_container_config_t *conf)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t file_size;
|
||||
|
||||
if (!util_file_exists(label_file)) {
|
||||
COMMAND_ERROR("label file not exists: %s", label_file);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
file_size = util_file_size(label_file);
|
||||
if (file_size > REGULAR_FILE_SIZE) {
|
||||
COMMAND_ERROR("label file '%s', size exceed limit: %lld", label_file, REGULAR_FILE_SIZE);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (read_label_from_file(label_file, file_size, conf) != 0) {
|
||||
COMMAND_ERROR("failed to read label from file: %s", label_file);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int request_pack_custom_label_file(const struct client_arguments *args, isula_container_config_t *conf)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t i;
|
||||
char **label_files = args->custom_conf.label_file;
|
||||
size_t label_files_size = util_array_len((const char **)label_files);
|
||||
if (label_files_size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < label_files_size; i++) {
|
||||
if (append_labels_to_conf(label_files[i], conf) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
conf->label_len = util_array_len((const char **)(conf->label));
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void request_pack_custom_user(const struct client_arguments *args, isula_container_config_t *conf)
|
||||
{
|
||||
if (args->custom_conf.user != NULL) {
|
||||
@ -577,17 +723,27 @@ static int request_pack_custom_conf(struct client_arguments *args, isula_contain
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Make sure --env has higher priority than --env-file */
|
||||
/* make sure --env has higher priority than --env-file */
|
||||
if (request_pack_custom_env(args, conf) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* append labels from label file */
|
||||
if (request_pack_custom_label_file(args, conf) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* make sure --label has higher priority than --label-file */
|
||||
if (request_pack_custom_label(args, conf) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* user and group */
|
||||
request_pack_custom_user(args, conf);
|
||||
|
||||
request_pack_custom_hostname(args, conf);
|
||||
|
||||
/* alldevices */
|
||||
/* all devices */
|
||||
request_pack_custom_all_devices(args, conf);
|
||||
|
||||
/* system container */
|
||||
@ -1225,6 +1381,7 @@ out:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int callback_annotation(command_option_t *option, const char *value)
|
||||
{
|
||||
struct client_arguments *args = (struct client_arguments *)option->data;
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CREATE_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "accel", 0, &(cmdargs).custom_conf.accel, \
|
||||
"Accelerator bindings (format: [<name>=]<runtime>[@<driver>[,<options>]])", \
|
||||
@ -49,6 +53,10 @@
|
||||
"Set environment variables", command_append_array }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "env-file", 0, &(cmdargs).custom_conf.env_file, \
|
||||
"Read in a file of environment variables", command_append_array }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "label", 'l', &(cmdargs).custom_conf.label, \
|
||||
"Set metadata on container (default [])", command_append_array }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "label-file", 0, &(cmdargs).custom_conf.label_file, \
|
||||
"Read in a line delimited file of labels (default [])", command_append_array }, \
|
||||
{ CMD_OPT_TYPE_STRING_DUP, false, "entrypoint", 0, &(cmdargs).custom_conf.entrypoint, \
|
||||
"Entrypoint to run when starting the container", NULL }, \
|
||||
{ CMD_OPT_TYPE_STRING, false, "external-rootfs", 0, &(cmdargs).external_rootfs, \
|
||||
@ -85,6 +93,8 @@
|
||||
"Memory soft limit", command_convert_membytes }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "memory-swap", 0, &(cmdargs).cr.memory_swap, \
|
||||
"Swap limit equal to memory plus swap: '-1' to enable unlimited swap", command_convert_memswapbytes }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "memory-swappiness", 0, &(cmdargs).cr.swappiness, \
|
||||
"Tune container memory swappiness (0 to 100) (default -1)", command_convert_swappiness }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "mount", 0, &(cmdargs).custom_conf.mounts, \
|
||||
"Attach a filesystem mount to the service", command_append_array }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "group-add", 0, &(cmdargs).custom_conf.group_add, \
|
||||
@ -169,5 +179,9 @@ int callback_annotation(command_option_t *option, const char *value);
|
||||
|
||||
int cmd_create_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_CREATE_H */
|
||||
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
#include "arguments.h"
|
||||
#include "wait.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KILL_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "signal", 's', &(cmdargs).signal, \
|
||||
"Signal to send to the container (default \"SIGKILL\")", NULL }
|
||||
@ -26,5 +30,10 @@ extern const char g_cmd_kill_desc[];
|
||||
extern const char g_cmd_kill_usage[];
|
||||
extern struct client_arguments g_cmd_kill_args;
|
||||
int cmd_kill_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_rename_desc[];
|
||||
extern const char g_cmd_rename_usage[];
|
||||
extern struct client_arguments g_cmd_rename_args;
|
||||
int cmd_rename_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
#ifndef __CMD_RESTART_H
|
||||
#define __CMD_RESTART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RESTART_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "time", 't', &(cmdargs).time, \
|
||||
"Seconds to wait for stop before killing it (default 10)", command_convert_int }
|
||||
@ -24,5 +28,9 @@ extern const char g_cmd_restart_usage[];
|
||||
extern struct client_arguments g_cmd_restart_args;
|
||||
int cmd_restart_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_RESTART_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DELETE_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "force", 'f', &(cmdargs).force, \
|
||||
"Force the removal of a running container (uses SIGKILL)", NULL }, \
|
||||
@ -28,5 +32,9 @@ extern const char g_cmd_delete_usage[];
|
||||
extern struct client_arguments g_cmd_delete_args;
|
||||
int cmd_delete_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_DELETE_H */
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ const char g_cmd_run_desc[] = "Run a command in a new container";
|
||||
const char g_cmd_run_usage[] = "run [OPTIONS] ROOTFS|IMAGE [COMMAND] [ARG...]";
|
||||
static int run_checker(struct client_arguments *args);
|
||||
struct client_arguments g_cmd_run_args = {
|
||||
.runtime = "lcr",
|
||||
.runtime = "",
|
||||
.restart = "no",
|
||||
.log_file = NULL,
|
||||
.log_file_size = "1MB",
|
||||
|
||||
@ -19,6 +19,10 @@
|
||||
#include "start.h"
|
||||
#include "wait.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RUN_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "detach", 'd', &(cmdargs).detach, \
|
||||
"Run container in background and print container ID", NULL }, \
|
||||
@ -30,5 +34,9 @@ extern const char g_cmd_run_usage[];
|
||||
extern struct client_arguments g_cmd_run_args;
|
||||
int cmd_run_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_RUN_H */
|
||||
|
||||
|
||||
@ -19,6 +19,10 @@
|
||||
#include "commands.h"
|
||||
#include <termios.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_start_desc[];
|
||||
extern struct client_arguments g_cmd_start_args;
|
||||
|
||||
@ -28,5 +32,10 @@ void client_restore_console(bool reset_tty, const struct termios *oldtios, struc
|
||||
int client_start(const struct client_arguments *args, bool *reset_tty, struct termios *oldtios,
|
||||
struct command_fifo_config **console_fifos);
|
||||
int cmd_start_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_START_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define STOP_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "force", 'f', &(cmdargs).force, "Stop by force killing", NULL }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "time", 't', &(cmdargs).time, \
|
||||
@ -28,5 +32,9 @@ extern struct client_arguments g_cmd_stop_args;
|
||||
|
||||
int cmd_stop_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_STOP_H */
|
||||
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
#include "arguments.h"
|
||||
#include <semaphore.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CLIENT_RUNDIR "/var/run/isula"
|
||||
|
||||
// A command is described by:
|
||||
@ -69,5 +73,10 @@ int commmand_default_help(const char * const program_name,
|
||||
const char **argv);
|
||||
|
||||
int run_command(struct command *commands, int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMMAND_H */
|
||||
|
||||
|
||||
@ -26,53 +26,119 @@ struct client_arguments g_cmd_events_args = {
|
||||
.until = NULL,
|
||||
};
|
||||
|
||||
static const char * const g_strtype[] = {
|
||||
"EXIT", "STOPPED", "STARTING", "RUNNING", "STOPPING", "ABORTING", "FREEZING",
|
||||
"FROZEN", "THAWED", "OOM", "CREATE", "START", "EXEC_ADDED", "PAUSED1",
|
||||
};
|
||||
|
||||
static const char *lcrsta2str(container_events_type_t sta)
|
||||
static size_t calacute_annotations_msg_len(const container_events_format_t *event)
|
||||
{
|
||||
if (sta > EVENTS_TYPE_PAUSED1) {
|
||||
size_t annos_msg_len = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < event->annotations_len; i++) {
|
||||
annos_msg_len += strlen(event->annotations[i]);
|
||||
}
|
||||
annos_msg_len += event->annotations_len * 2;
|
||||
|
||||
return annos_msg_len;
|
||||
}
|
||||
|
||||
static size_t calacute_event_msg_len(const container_events_format_t *event, const char *timebuffer)
|
||||
{
|
||||
size_t msg_len = 0;
|
||||
// format : timestamp (container|image opt) id (annotaions)
|
||||
msg_len += strlen(timebuffer) + 1 + strlen(event->opt) + 1 + strlen(event->id) + 1;
|
||||
msg_len += calacute_annotations_msg_len(event);
|
||||
msg_len += 1; // '\0'
|
||||
|
||||
return msg_len;
|
||||
}
|
||||
|
||||
static int generate_annotations_msg(const container_events_format_t *event, char **anno_msg)
|
||||
{
|
||||
size_t i;
|
||||
size_t anno_msg_len = calacute_annotations_msg_len(event) + 1;
|
||||
|
||||
if (anno_msg_len == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*anno_msg = (char *)util_common_calloc_s(anno_msg_len);
|
||||
if (*anno_msg == NULL) {
|
||||
ERROR("Event: Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)strcat(*anno_msg, "(");
|
||||
for (i = 0; i < event->annotations_len; i++) {
|
||||
(void)strcat(*anno_msg, event->annotations[i]);
|
||||
if (i != event->annotations_len - 1) {
|
||||
(void)strcat(*anno_msg, ", ");
|
||||
}
|
||||
}
|
||||
(void)strcat(*anno_msg, ")");
|
||||
(*anno_msg)[anno_msg_len - 1] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *generate_event_msg(const container_events_format_t *event, const char *timebuffer, size_t len)
|
||||
{
|
||||
int nret = 0;
|
||||
char *anno_msg = NULL;
|
||||
char *msg = NULL;
|
||||
|
||||
if (generate_annotations_msg(event, &anno_msg) != 0) {
|
||||
ERROR("Event: Failed to generate annotations msg");
|
||||
return NULL;
|
||||
}
|
||||
return g_strtype[sta];
|
||||
|
||||
msg = (char *)util_common_calloc_s(len);
|
||||
if (msg == NULL) {
|
||||
ERROR("Event: Out of memory");
|
||||
goto err_out;
|
||||
}
|
||||
if (anno_msg != NULL) {
|
||||
nret = snprintf(msg, len, "%s %s %s %s", timebuffer, event->opt, event->id, anno_msg);
|
||||
} else {
|
||||
nret = snprintf(msg, len, "%s %s %s", timebuffer, event->opt, event->id);
|
||||
}
|
||||
if (nret < 0 || (size_t)nret >= len) {
|
||||
ERROR("Event: compose event massage failed");
|
||||
goto err_out;
|
||||
}
|
||||
msg[len - 1] = '\0';
|
||||
|
||||
free(anno_msg);
|
||||
return msg;
|
||||
|
||||
err_out:
|
||||
free(anno_msg);
|
||||
free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void print_events_callback(const container_events_format_t *event)
|
||||
{
|
||||
char timebuffer[512] = { 0 };
|
||||
char *msg = NULL;
|
||||
size_t msg_len = 0;
|
||||
|
||||
if (event == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("--------------------------------------------------\n");
|
||||
printf("%-15s %s\n", "Name:", event->id);
|
||||
|
||||
if (get_time_buffer(&(event->timestamp), timebuffer, sizeof(timebuffer))) {
|
||||
printf("%-15s %s\n", "Time:", timebuffer);
|
||||
} else {
|
||||
printf("%-15s %s\n", "Time:", "-");
|
||||
if (!get_time_buffer(&(event->timestamp), timebuffer, sizeof(timebuffer))) {
|
||||
(void)strcpy(timebuffer, "-");
|
||||
}
|
||||
|
||||
if (event->has_type) {
|
||||
printf("%-15s %s\n", "EventType:", lcrsta2str(event->type));
|
||||
} else {
|
||||
printf("%-15s %s\n", "EventType:", "-");
|
||||
msg_len = calacute_event_msg_len(event, timebuffer);
|
||||
|
||||
msg = generate_event_msg(event, timebuffer, msg_len);
|
||||
if (msg == NULL) {
|
||||
printf("generate event message failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->has_pid) {
|
||||
printf("%-15s %u\n", "Pid:", event->pid);
|
||||
} else {
|
||||
printf("%-15s %s\n", "Pid:", "-");
|
||||
}
|
||||
printf("%s\n", msg);
|
||||
|
||||
if (event->has_exit_status) {
|
||||
printf("%-15s %u\n", "Exit_Status:", event->exit_status);
|
||||
} else {
|
||||
printf("%-15s %s\n", "Exit_Status:", "-");
|
||||
}
|
||||
free(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -116,7 +182,7 @@ static int client_event(struct client_arguments *args)
|
||||
|
||||
config = get_connect_config(args);
|
||||
ret = ops->container.events(&request, response, &config);
|
||||
if (ret) {
|
||||
if (ret != 0) {
|
||||
COMMAND_ERROR("Failed to get container events, %s",
|
||||
response->errmsg ? response->errmsg : errno_to_error_message(response->cc));
|
||||
}
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EVENTS_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "name", 'n', &(cmdargs).name, \
|
||||
"Name of the container", NULL }, \
|
||||
@ -30,5 +34,9 @@ extern const char g_cmd_events_usage[];
|
||||
extern struct client_arguments g_cmd_events_args;
|
||||
int cmd_events_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_EVENT_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EXPORT_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "output", 'o', &(cmdargs).file, "Write to a file", NULL }
|
||||
|
||||
@ -25,5 +29,9 @@ extern const char g_cmd_export_usage[];
|
||||
extern struct client_arguments g_cmd_export_args;
|
||||
int cmd_export_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_pause_desc[];
|
||||
extern const char g_cmd_pause_usage[];
|
||||
extern struct client_arguments g_cmd_pause_args;
|
||||
int cmd_pause_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_resume_desc[];
|
||||
extern const char g_cmd_resume_usage[];
|
||||
extern struct client_arguments g_cmd_resume_args;
|
||||
int cmd_resume_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define STATUS_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "all", 'a', &(cmdargs).showall, \
|
||||
"Show all containers (default shows just running)", NULL }, \
|
||||
@ -28,5 +32,9 @@ extern const char g_cmd_stats_usage[];
|
||||
extern struct client_arguments g_cmd_stats_args;
|
||||
int cmd_stats_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_STATS_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UPDATE_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "cpu-shares", 0, &(cmdargs).cr.cpu_shares, \
|
||||
"CPU shares (relative weight)", command_convert_llong }, \
|
||||
@ -45,5 +49,9 @@ extern struct client_arguments g_cmd_update_args;
|
||||
int cmd_update_main(int argc, const char **argv);
|
||||
int update_checker(const struct client_arguments *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_UPDATE_H */
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_images_desc[];
|
||||
extern const char g_cmd_images_usage[];
|
||||
extern struct client_arguments g_cmd_images_args;
|
||||
int cmd_images_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_IMAGES_LIST_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOAD_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "input", 'i', &(cmdargs).file, "Read from a manifest or an archive", NULL }, \
|
||||
{ CMD_OPT_TYPE_STRING, false, "tag", 0, &(cmdargs).tag, \
|
||||
@ -29,5 +33,9 @@ extern const char g_cmd_load_desc[];
|
||||
extern struct client_arguments g_cmd_load_args;
|
||||
int cmd_load_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_LOAD_H */
|
||||
|
||||
|
||||
@ -16,6 +16,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOGIN_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "username", 'u', &(cmdargs).username, "Username", NULL }, \
|
||||
{ CMD_OPT_TYPE_STRING, false, "password", 'p', &(cmdargs).password, "Password", NULL }, \
|
||||
@ -28,5 +32,9 @@ extern const char g_cmd_login_usage[];
|
||||
extern struct client_arguments g_cmd_login_args;
|
||||
int cmd_login_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_LOGIN_H */
|
||||
|
||||
|
||||
@ -16,10 +16,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_logout_desc[];
|
||||
extern const char g_cmd_logout_usage[];
|
||||
extern struct client_arguments g_cmd_logout_args;
|
||||
int cmd_logout_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_LOGOUT_H */
|
||||
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_pull_desc[];
|
||||
extern const char g_cmd_pull_usage[];
|
||||
extern struct client_arguments g_cmd_pull_args;
|
||||
@ -25,5 +29,9 @@ int client_pull(const struct client_arguments *args);
|
||||
|
||||
int cmd_pull_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_PULL_IMAGE_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RMI_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "force", 'f', &(cmdargs).force, "Force removal of the image", NULL }
|
||||
|
||||
@ -25,5 +29,9 @@ extern const char g_cmd_rmi_usage[];
|
||||
extern struct client_arguments g_cmd_rmi_args;
|
||||
int cmd_rmi_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_REMOVE_IMAGE_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HEALTH_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "service", 'S', &(cmdargs).service, "GRPC service name", NULL }
|
||||
|
||||
@ -25,5 +29,9 @@ extern const char g_cmd_health_check_usage[];
|
||||
extern struct client_arguments g_cmd_health_check_args;
|
||||
int cmd_health_check_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_info_desc[];
|
||||
extern const char g_cmd_info_usage[];
|
||||
extern struct client_arguments g_cmd_info_args;
|
||||
int cmd_info_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_INFO_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INSPECT_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_STRING, false, "format", 'f', &(cmdargs).format, \
|
||||
"Format the output using the given go template", NULL }, \
|
||||
@ -28,5 +32,9 @@ extern const char g_cmd_inspect_usage[];
|
||||
extern struct client_arguments g_cmd_inspect_args;
|
||||
int cmd_inspect_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_INSPECT_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOGS_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "follow", 'f', &(cmdargs).follow, "Follow log output", NULL }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "tail", 0, &(cmdargs).tail, \
|
||||
@ -28,5 +32,10 @@ extern struct client_arguments g_cmd_logs_args;
|
||||
|
||||
int callback_tail(command_option_t *option, const char *arg);
|
||||
int cmd_logs_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_LOGS_H */
|
||||
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIST_OPTIONS(cmdargs) \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "all", 'a', &(cmdargs).list_all, \
|
||||
"Display all containers (default shows just running)", NULL }, \
|
||||
@ -33,5 +37,9 @@ extern const char g_cmd_list_usage[];
|
||||
extern struct client_arguments g_cmd_list_args;
|
||||
int cmd_list_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_LIST_H */
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_top_desc[];
|
||||
extern const char g_cmd_top_usage[];
|
||||
extern struct client_arguments g_cmd_top_args;
|
||||
int cmd_top_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_TOP_H */
|
||||
|
||||
|
||||
@ -17,10 +17,18 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_version_desc[];
|
||||
extern const char g_cmd_version_usage[];
|
||||
extern struct client_arguments g_cmd_version_args;
|
||||
int cmd_version_main(int argc, const char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_VERSION_H */
|
||||
|
||||
|
||||
@ -17,11 +17,19 @@
|
||||
|
||||
#include "arguments.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char g_cmd_wait_desc[];
|
||||
extern const char g_cmd_wait_usage[];
|
||||
extern struct client_arguments g_cmd_wait_args;
|
||||
int cmd_wait_main(int argc, const char **argv);
|
||||
int client_wait(const struct client_arguments *args, unsigned int *exit_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CMD_WAIT_H */
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include "pause.h"
|
||||
#include "resume.h"
|
||||
#include "logs.h"
|
||||
#include "events.h"
|
||||
#include "kill.h"
|
||||
#include "load.h"
|
||||
#include "update.h"
|
||||
@ -137,6 +138,10 @@ struct command g_commands[] = {
|
||||
// `logs` sub-command
|
||||
"logs", cmd_logs_main, g_cmd_logs_desc, NULL, &g_cmd_logs_args
|
||||
},
|
||||
{
|
||||
// `events` sub-command
|
||||
"events", cmd_events_main, g_cmd_events_desc, NULL, &g_cmd_events_args
|
||||
},
|
||||
#endif
|
||||
{
|
||||
// `kill` sub-command
|
||||
|
||||
12
src/cmd/isulad-shim/CMakeLists.txt
Normal file
12
src/cmd/isulad-shim/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# get current directory sources files
|
||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} isulad_shim_srcs)
|
||||
|
||||
set(CMD_ISULAD_SHIM_SRCS
|
||||
${isulad_shim_srcs}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(CMD_ISULAD_SHIM_INCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
301
src/cmd/isulad-shim/common.c
Normal file
301
src/cmd/isulad-shim/common.c
Normal file
@ -0,0 +1,301 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
* iSulad licensed under the Mulan PSL v1.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||
* You may obtain a copy of Mulan PSL v1 at:
|
||||
* http://license.coscl.org.cn/MulanPSL
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v1 for more details.
|
||||
* Author: leizhongkai
|
||||
* Create: 2020-1-21
|
||||
* Description: common functions of isulad-shim
|
||||
******************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <linux/limits.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern int g_log_fd;
|
||||
|
||||
int set_fd_no_inherited(int fd)
|
||||
{
|
||||
int ret = SHIM_ERR;
|
||||
int flag = -1;
|
||||
|
||||
flag = fcntl(fd, F_GETFD, 0);
|
||||
if (flag < 0) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
ret = fcntl(fd, F_SETFD, flag | FD_CLOEXEC);
|
||||
if (ret != 0) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
return SHIM_OK;
|
||||
}
|
||||
|
||||
ssize_t read_nointr(int fd, void *buf, size_t count)
|
||||
{
|
||||
ssize_t nret;
|
||||
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
nret = read(fd, buf, count);
|
||||
if (nret < 0 && (errno == EINTR || errno == EAGAIN)) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nret;
|
||||
}
|
||||
|
||||
ssize_t write_nointr(int fd, const void *buf, size_t count)
|
||||
{
|
||||
ssize_t nret;
|
||||
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
nret = write(fd, buf, count);
|
||||
if (nret < 0 && (errno == EINTR || errno == EAGAIN)) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nret;
|
||||
}
|
||||
|
||||
bool file_exists(const char *f)
|
||||
{
|
||||
struct stat buf;
|
||||
int nret;
|
||||
|
||||
if (f == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nret = stat(f, &buf);
|
||||
if (nret < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int cmd_combined_output(const char *binary, const char *params[], void *output, int *output_len)
|
||||
{
|
||||
int ret = SHIM_ERR;
|
||||
int exec_fd[2] = { -1, -1 };
|
||||
int stdio[2] = { -1, -1 };
|
||||
pid_t pid = 0;
|
||||
char exec_buff[BUFSIZ + 1] = { 0 };
|
||||
ssize_t nread;
|
||||
|
||||
if (pipe2(exec_fd, O_CLOEXEC) != 0) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
if (pipe2(stdio, O_CLOEXEC) != 0) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == (pid_t) - 1) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
// child
|
||||
if (pid == (pid_t)0) {
|
||||
close(exec_fd[0]);
|
||||
close(stdio[0]);
|
||||
dup2(stdio[1], 1);
|
||||
dup2(stdio[1], 2);
|
||||
execvp(binary, (char * const *)params);
|
||||
(void)dprintf(exec_fd[1], "fork/exec error: %s", strerror(errno));
|
||||
}
|
||||
|
||||
// parent
|
||||
close(exec_fd[1]);
|
||||
close(stdio[1]);
|
||||
nread = read_nointr(exec_fd[0], exec_buff, sizeof(exec_buff));
|
||||
if (nread > 0) {
|
||||
ret = SHIM_ERR;
|
||||
goto out;
|
||||
}
|
||||
*output_len = read_nointr(stdio[0], output, 8191);
|
||||
|
||||
close(stdio[0]);
|
||||
close(exec_fd[0]);
|
||||
int status = 0;
|
||||
wait(&status);
|
||||
ret = SHIM_OK;
|
||||
out:
|
||||
if (ret != SHIM_OK && pid != 0) {
|
||||
kill(pid, 9);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int generate_random_str(char *id, size_t len)
|
||||
{
|
||||
int fd = -1;
|
||||
int num = 0;
|
||||
size_t i;
|
||||
const int m = 256;
|
||||
|
||||
len = len / 2;
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd == -1) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
int nret;
|
||||
if (read(fd, &num, sizeof(int)) < 0) {
|
||||
close(fd);
|
||||
return SHIM_ERR;
|
||||
}
|
||||
unsigned char rs = (unsigned char)(num % m);
|
||||
nret = snprintf((id + i * 2), ((len - i) * 2 + 1), "%02x", (unsigned int)rs);
|
||||
if (nret < 0) {
|
||||
close(fd);
|
||||
return SHIM_ERR;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
id[i * 2] = '\0';
|
||||
|
||||
return SHIM_OK;
|
||||
}
|
||||
|
||||
void write_message(int fd, const char *level, const char *fmt, ...)
|
||||
{
|
||||
#define MAX_MSG_JSON_TEMPLATE 32
|
||||
#define MAX_MESSAGE_CONTENT_LEN 128
|
||||
#define MAX_MESSAGE_LEN (MAX_MSG_JSON_TEMPLATE + MAX_MESSAGE_CONTENT_LEN)
|
||||
if (fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[MAX_MESSAGE_CONTENT_LEN] = { 0 };
|
||||
char msg[MAX_MESSAGE_LEN] = { 0 };
|
||||
int nwrite = -1;
|
||||
|
||||
va_list arg_list;
|
||||
va_start(arg_list, fmt);
|
||||
vsnprintf(buf, MAX_MESSAGE_CONTENT_LEN, fmt, arg_list);
|
||||
va_end(arg_list);
|
||||
|
||||
snprintf(msg, MAX_MESSAGE_LEN - 1, "{\"level\": \"%s\", \"msg\": \"%s\"}\n", level, buf);
|
||||
nwrite = write(fd, msg, strlen(msg));
|
||||
if (nwrite != strlen(msg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* note: This function can only read small text file. */
|
||||
char *read_text_file(const char *path)
|
||||
{
|
||||
char *buf = NULL;
|
||||
long len = 0;
|
||||
size_t readlen = 0;
|
||||
FILE *filp = NULL;
|
||||
const long max_size = 10 * 1024 * 1024; /* 10M */
|
||||
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
filp = fopen(path, "r");
|
||||
if (filp == NULL) {
|
||||
goto err_out;
|
||||
}
|
||||
if (fseek(filp, 0, SEEK_END)) {
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
len = ftell(filp);
|
||||
if (len > max_size) {
|
||||
goto err_out;
|
||||
}
|
||||
if (fseek(filp, 0, SEEK_SET)) {
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
buf = (char *)calloc(1, (size_t)(len + 1));
|
||||
if (buf == NULL) {
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
readlen = fread(buf, 1, (size_t)len, filp);
|
||||
if (((readlen < (size_t)len) && (!feof(filp))) || (readlen > (size_t)len)) {
|
||||
if (buf != NULL) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
buf[(size_t)len] = 0;
|
||||
|
||||
err_out:
|
||||
|
||||
if (filp != NULL) {
|
||||
fclose(filp);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void close_fd(int *pfd)
|
||||
{
|
||||
if (pfd != NULL && *pfd != -1) {
|
||||
close(*pfd);
|
||||
*pfd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int open_no_inherit(const char *path, int flag, mode_t mode)
|
||||
{
|
||||
int fd = -1;
|
||||
int ret = SHIM_ERR;
|
||||
|
||||
fd = open(path, flag, mode);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = set_fd_no_inherited(fd);
|
||||
if (ret != SHIM_OK) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
72
src/cmd/isulad-shim/common.h
Normal file
72
src/cmd/isulad-shim/common.h
Normal file
@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
* iSulad licensed under the Mulan PSL v1.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||
* You may obtain a copy of Mulan PSL v1 at:
|
||||
* http://license.coscl.org.cn/MulanPSL
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v1 for more details.
|
||||
* Author: leizhongkai
|
||||
* Create: 2020-1-20
|
||||
* Description: common definition of isulad-shim
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __COMMON_H_
|
||||
#define __COMMON_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// error code
|
||||
#define SHIM_ERR_BASE (-10000)
|
||||
#define SHIM_SYS_ERR(err) (SHIM_ERR_BASE-err)
|
||||
#define SHIM_OK 0
|
||||
#define SHIM_ERR -1
|
||||
#define SHIM_ERR_WAIT -2
|
||||
#define SHIM_ERR_NOT_REQUIRED -3
|
||||
|
||||
#define INFO_MSG "info"
|
||||
#define WARN_MSG "warn"
|
||||
#define ERR_MSG "error"
|
||||
|
||||
#define DEFAULT_TIMEOUT 120 // sec
|
||||
#define CONTAINER_ID_LEN 64
|
||||
#define MAX_RT_NAME_LEN 64
|
||||
#define MAX_CONSOLE_SOCK_LEN 32
|
||||
|
||||
#define MAX_RUNTIME_ARGS 20
|
||||
|
||||
#define SHIM_BINARY "isulad-shim"
|
||||
#define SHIM_LOG_NAME "shim-log.json"
|
||||
|
||||
#define CONTAINER_ACTION_REBOOT 129
|
||||
#define CONTAINER_ACTION_SHUTDOWN 130
|
||||
|
||||
ssize_t read_nointr(int fd, void *buf, size_t count);
|
||||
ssize_t write_nointr(int fd, const void *buf, size_t count);
|
||||
|
||||
char *read_text_file(const char *path);
|
||||
|
||||
bool file_exists(const char *f);
|
||||
|
||||
int cmd_combined_output(const char *binary, const char *params[], void *output, int *output_len);
|
||||
|
||||
void write_message(int fd, const char *level, const char *fmt, ...);
|
||||
|
||||
int generate_random_str(char *id, size_t len);
|
||||
|
||||
void close_fd(int *pfd);
|
||||
|
||||
int open_no_inherit(const char *path, int flag, mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
162
src/cmd/isulad-shim/main.c
Normal file
162
src/cmd/isulad-shim/main.c
Normal file
@ -0,0 +1,162 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
* iSulad licensed under the Mulan PSL v1.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||
* You may obtain a copy of Mulan PSL v1 at:
|
||||
* http://license.coscl.org.cn/MulanPSL
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v1 for more details.
|
||||
* Author: leizhongkai
|
||||
* Create: 2020-1-20
|
||||
* Description: main process of isulad-shim
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "process.h"
|
||||
|
||||
int g_log_fd = -1;
|
||||
|
||||
void signal_routine(int sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case SIGALRM:
|
||||
write_message(g_log_fd, ERR_MSG, "runtime timeout");
|
||||
exit(1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_timeout_exit(unsigned int timeout)
|
||||
{
|
||||
signal(SIGALRM, signal_routine);
|
||||
(void)alarm(timeout);
|
||||
}
|
||||
|
||||
static void released_timeout_exit()
|
||||
{
|
||||
(void)alarm(0);
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
}
|
||||
|
||||
static int set_subreaper()
|
||||
{
|
||||
int ret = SHIM_ERR;
|
||||
ret = prctl(PR_SET_CHILD_SUBREAPER, 1);
|
||||
if (ret != SHIM_OK) {
|
||||
return SHIM_SYS_ERR(errno);
|
||||
}
|
||||
|
||||
return SHIM_OK;
|
||||
}
|
||||
|
||||
static int parse_args(int argc, char **argv, char **cid, char **bundle, char **rt_name, char **log_level)
|
||||
{
|
||||
if (argc < 4) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
*cid = strdup(argv[1]);
|
||||
*bundle = strdup(argv[2]);
|
||||
*rt_name = strdup(argv[3]);
|
||||
if (*cid == NULL || *bundle == NULL || rt_name == NULL) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
|
||||
if (argc > 4) {
|
||||
*log_level = strdup(argv[4]);
|
||||
if (*log_level == NULL) {
|
||||
return SHIM_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return SHIM_OK;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *container_id = NULL;
|
||||
char *bundle = NULL;
|
||||
char *rt_name = NULL;
|
||||
char *log_level = NULL;
|
||||
int ret = SHIM_ERR;
|
||||
int efd = -1;
|
||||
process_t *p = NULL;
|
||||
|
||||
g_log_fd = open_no_inherit(SHIM_LOG_NAME, O_CREAT | O_WRONLY | O_APPEND | O_SYNC, 0640);
|
||||
if (g_log_fd < 0) {
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_timeout_exit(DEFAULT_TIMEOUT);
|
||||
|
||||
ret = set_subreaper();
|
||||
if (ret != SHIM_OK) {
|
||||
write_message(g_log_fd, ERR_MSG, "set subreaper failed:%d", ret);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = parse_args(argc, argv, &container_id, &bundle, &rt_name, &log_level);
|
||||
if (ret != SHIM_OK) {
|
||||
write_message(g_log_fd, ERR_MSG, "parse args failed:%d", ret);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
p = new_process(container_id, bundle, rt_name);
|
||||
if (p == NULL) {
|
||||
write_message(g_log_fd, ERR_MSG, "new process failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// open exit pipe
|
||||
if (!p->state->exec) {
|
||||
if (p->state->exit_fifo != NULL) {
|
||||
efd = open_no_inherit("exit_fifo", O_WRONLY, -1);
|
||||
if (efd < 0) {
|
||||
write_message(g_log_fd, ERR_MSG, "open exit pipe failed:%d", SHIM_SYS_ERR(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
p->exit_fd = efd;
|
||||
}
|
||||
}
|
||||
|
||||
// create main loop and start epoll
|
||||
ret = process_io_init(p);
|
||||
if (ret != SHIM_OK) {
|
||||
write_message(g_log_fd, ERR_MSG, "process io init failed:%d", ret);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = open_io(p);
|
||||
if (ret != SHIM_OK) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = create_process(p);
|
||||
if (ret != SHIM_OK) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
released_timeout_exit();
|
||||
|
||||
ret = process_signal_handle_routine(p);
|
||||
if (ret != SHIM_OK) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
1018
src/cmd/isulad-shim/process.c
Normal file
1018
src/cmd/isulad-shim/process.c
Normal file
File diff suppressed because it is too large
Load Diff
100
src/cmd/isulad-shim/process.h
Normal file
100
src/cmd/isulad-shim/process.h
Normal file
@ -0,0 +1,100 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
* iSulad licensed under the Mulan PSL v1.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v1.
|
||||
* You may obtain a copy of Mulan PSL v1 at:
|
||||
* http://license.coscl.org.cn/MulanPSL
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v1 for more details.
|
||||
* Author: leizhongkai
|
||||
* Create: 2020-1-20
|
||||
* Description: process definition
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __SHIM_PROCESS_H_
|
||||
#define __SHIM_PROCESS_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdbool.h>
|
||||
#include "shim_client_process_state.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
stdid_in = 0,
|
||||
stdid_out,
|
||||
stdid_err
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int in;
|
||||
int out;
|
||||
int err;
|
||||
} stdio_t;
|
||||
|
||||
typedef struct fd_node {
|
||||
int fd;
|
||||
struct fd_node *next;
|
||||
} fd_node_t;
|
||||
|
||||
typedef struct {
|
||||
int fd_from;
|
||||
fd_node_t *fd_to;
|
||||
int id;// 0,1,2
|
||||
pthread_mutex_t mutex;
|
||||
} io_copy_t;
|
||||
|
||||
typedef struct {
|
||||
int epfd;
|
||||
pthread_t tid;
|
||||
pthread_attr_t attr;
|
||||
sem_t sem_thd;
|
||||
io_copy_t *ioc;
|
||||
bool shutdown;
|
||||
} io_thread_t;
|
||||
|
||||
typedef struct process {
|
||||
char *id;
|
||||
char *bundle;
|
||||
char *runtime;
|
||||
char *console_sock_path;
|
||||
int io_loop_fd;
|
||||
int exit_fd;
|
||||
int ctr_pid;
|
||||
stdio_t *stdio;
|
||||
stdio_t *shim_io;
|
||||
io_thread_t *io_threads[3];// stdin,stdout,stderr
|
||||
shim_client_process_state *state;
|
||||
} process_t;
|
||||
|
||||
typedef struct {
|
||||
int listen_fd;
|
||||
process_t *p;
|
||||
} console_accept_t;
|
||||
|
||||
typedef struct {
|
||||
int pid;
|
||||
int status;
|
||||
} process_exit_t;
|
||||
|
||||
|
||||
|
||||
process_t* new_process(char *id, char *bundle, char *runtime);
|
||||
|
||||
int open_io(process_t *p);
|
||||
int process_io_init(process_t *p);
|
||||
int create_process(process_t *p);
|
||||
int process_signal_handle_routine(process_t *p);
|
||||
void process_delete(process_t *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -157,6 +157,7 @@ int service_arguments_init(struct service_arguments *args)
|
||||
args->default_ulimit = NULL;
|
||||
args->default_ulimit_len = 0;
|
||||
args->json_confs->websocket_server_listening_port = DEFAULT_WEBSOCKET_SERVER_LISTENING_PORT;
|
||||
args->json_confs->selinux_enabled = false;
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@ -102,7 +102,9 @@ int update_default_ulimit(struct service_arguments *args);
|
||||
"Default ulimits for containers (default [])", command_default_ulimit_append }, \
|
||||
{ CMD_OPT_TYPE_CALLBACK, false, "websocket-server-listening-port", 0, \
|
||||
&(cmdargs)->json_confs->websocket_server_listening_port, \
|
||||
"CRI websocket streaming service listening port (default 10350)", command_convert_uint }
|
||||
"CRI websocket streaming service listening port (default 10350)", command_convert_uint }, \
|
||||
{ CMD_OPT_TYPE_BOOL, false, "selinux-enabled", 0, &(cmdargs)->json_confs->selinux_enabled, \
|
||||
"Enable selinux support", NULL}
|
||||
|
||||
#endif /* __COMMAND_H */
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
@ -56,6 +57,7 @@
|
||||
#include "supervisor.h"
|
||||
#include "containers_gc.h"
|
||||
#include "plugin.h"
|
||||
#include "selinux_label.h"
|
||||
|
||||
|
||||
#ifdef ENABLE_OCI_IMAGE
|
||||
@ -772,6 +774,80 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int overlay_supports_selinux(bool *supported)
|
||||
{
|
||||
#define KALLSYMS_ITEM_MAX_LEN 100
|
||||
int ret = 0;
|
||||
FILE *fp = NULL;
|
||||
char *buf = NULL;
|
||||
size_t len;
|
||||
ssize_t num;
|
||||
|
||||
*supported = false;
|
||||
fp = fopen("/proc/kallsyms", "re");
|
||||
if (fp == NULL) {
|
||||
ERROR("Failed to open /proc/kallsyms: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
__fsetlocking(fp, FSETLOCKING_BYCALLER);
|
||||
|
||||
for (num = getline(&buf, &len, fp); num != -1; num = getline(&buf, &len, fp)) {
|
||||
char sym_addr[KALLSYMS_ITEM_MAX_LEN] = { 0 };
|
||||
char sym_type[KALLSYMS_ITEM_MAX_LEN] = { 0 };
|
||||
char sym_name[KALLSYMS_ITEM_MAX_LEN] = { 0 };
|
||||
|
||||
if (sscanf(buf, "%s %s %s", sym_addr, sym_type, sym_name) != 3) {
|
||||
ERROR("sscanf buffer failed");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Check for presence of symbol security_inode_copy_up.
|
||||
if (strcmp(sym_name, "security_inode_copy_up") == 0) {
|
||||
*supported = true;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
fclose(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int configure_kernel_security_support(const struct service_arguments *args)
|
||||
{
|
||||
if (selinux_state_init() != 0) {
|
||||
ERROR("Failed to init selinux state");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (args->json_confs->selinux_enabled) {
|
||||
if (!selinux_get_enable()) {
|
||||
WARN("iSulad could not enable SELinux on the host system");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(args->json_confs->storage_driver, "overlay") == 0 ||
|
||||
strcmp(args->json_confs->storage_driver, "overlay2") == 0) {
|
||||
// If driver is overlay or overlay2, make sure kernel
|
||||
// supports selinux with overlay.
|
||||
bool supported = false;
|
||||
|
||||
if (overlay_supports_selinux(&supported)) {
|
||||
return -1;
|
||||
}
|
||||
if (!supported) {
|
||||
WARN("SELinux is not supported with the %s graph driver on this kernel",
|
||||
args->json_confs->storage_driver);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selinux_set_disabled();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int update_server_args(struct service_arguments *args)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -819,6 +895,13 @@ static int update_server_args(struct service_arguments *args)
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
|
||||
// operation only, so it is safe to pass *just* the runtime OS graphdriver.
|
||||
if (configure_kernel_security_support(args)) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OCI_IMAGE
|
||||
args->driver = graphdriver_init(args->json_confs->storage_driver, args->json_confs->storage_opts,
|
||||
args->json_confs->storage_opts_len);
|
||||
|
||||
@ -806,7 +806,7 @@ char *conf_get_isulad_log_gather_fifo_path()
|
||||
ERROR("Out of memory");
|
||||
goto err_out;
|
||||
}
|
||||
nret = snprintf(logfile, len, "%s%s", statedir, "LOG_GATHER_FIFO_NAME");
|
||||
nret = snprintf(logfile, len, "%s%s", statedir, LOG_GATHER_FIFO_NAME);
|
||||
if (nret < 0 || (size_t)nret >= len) {
|
||||
ERROR("Sprintf log file failed");
|
||||
goto err_out;
|
||||
@ -1206,6 +1206,28 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
char *conf_get_default_runtime()
|
||||
{
|
||||
struct service_arguments *conf = NULL;
|
||||
char *result = NULL;
|
||||
|
||||
if (isulad_server_conf_rdlock()) {
|
||||
ERROR("BUG conf_rdlock failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conf = conf_get_server_conf();
|
||||
if (conf == NULL || conf->json_confs == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = strings_to_lower(conf->json_confs->default_runtime);
|
||||
|
||||
out:
|
||||
(void)isulad_server_conf_unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool conf_update_im_server_sock_addr(const char *new_sock_addr)
|
||||
{
|
||||
struct service_arguments *conf = NULL;
|
||||
@ -1765,6 +1787,7 @@ int merge_json_confs_into_global(struct service_arguments *args)
|
||||
goto out;
|
||||
}
|
||||
|
||||
override_string_value(&args->json_confs->default_runtime, &tmp_json_confs->default_runtime);
|
||||
override_string_value(&args->json_confs->group, &tmp_json_confs->group);
|
||||
override_string_value(&args->json_confs->graph, &tmp_json_confs->graph);
|
||||
override_string_value(&args->json_confs->state, &tmp_json_confs->state);
|
||||
@ -1790,6 +1813,9 @@ int merge_json_confs_into_global(struct service_arguments *args)
|
||||
override_string_value(&args->json_confs->cni_bin_dir, &tmp_json_confs->cni_bin_dir);
|
||||
override_string_value(&args->json_confs->cni_conf_dir, &tmp_json_confs->cni_conf_dir);
|
||||
|
||||
args->json_confs->runtimes = tmp_json_confs->runtimes;
|
||||
tmp_json_confs->runtimes = NULL;
|
||||
|
||||
// Daemon storage-driver
|
||||
if (merge_storage_conf_into_global(args, tmp_json_confs)) {
|
||||
ret = -1;
|
||||
@ -1836,6 +1862,8 @@ int merge_json_confs_into_global(struct service_arguments *args)
|
||||
goto out;
|
||||
}
|
||||
|
||||
args->json_confs->selinux_enabled = tmp_json_confs->selinux_enabled;
|
||||
|
||||
out:
|
||||
free(err);
|
||||
free_isulad_daemon_configs(tmp_json_confs);
|
||||
|
||||
@ -25,6 +25,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEFAULT_IM_SERVER_SOCK_ADDR "unix:///var/run/isulad/isula_image.sock"
|
||||
#define DEFAULT_RUNTIME_NAME "lcr"
|
||||
|
||||
struct isulad_conf {
|
||||
pthread_rwlock_t isulad_conf_rwlock;
|
||||
@ -92,6 +93,8 @@ unsigned int conf_get_im_opt_timeout();
|
||||
|
||||
char *conf_get_im_server_sock_addr();
|
||||
|
||||
char *conf_get_default_runtime();
|
||||
|
||||
bool conf_update_im_server_sock_addr(const char *new_sock_addr);
|
||||
|
||||
char *conf_get_graph_check_flag_file();
|
||||
|
||||
@ -113,16 +113,12 @@ public:
|
||||
context.set_deadline(tDeadline);
|
||||
}
|
||||
|
||||
// Set common name from cert.perm
|
||||
char common_name_value[ClientBaseConstants::COMMON_NAME_LEN] = { 0 };
|
||||
ret = get_common_name_from_tls_cert(m_certFile.c_str(), common_name_value,
|
||||
ClientBaseConstants::COMMON_NAME_LEN);
|
||||
if (ret != 0) {
|
||||
ERROR("Failed to get common name in: %s", m_certFile.c_str());
|
||||
// Set metadata for authorization
|
||||
if (SetMetadataInfo(context) != 0) {
|
||||
ERROR("Failed to set metadata info for authorization");
|
||||
response->cc = ISULAD_ERR_INPUT;
|
||||
return -1;
|
||||
}
|
||||
context.AddMetadata("username", std::string(common_name_value, strlen(common_name_value)));
|
||||
context.AddMetadata("tls_mode", m_tlsMode);
|
||||
|
||||
ret = request_to_grpc(request, &req);
|
||||
if (ret != 0) {
|
||||
@ -175,7 +171,7 @@ protected:
|
||||
return Status::OK;
|
||||
};
|
||||
|
||||
static std::string ReadTextFile(const char *file)
|
||||
std::string ReadTextFile(const char *file)
|
||||
{
|
||||
char *real_file = verify_file_and_get_real_path(file);
|
||||
if (real_file == nullptr) {
|
||||
@ -195,6 +191,22 @@ protected:
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int SetMetadataInfo(ClientContext &context)
|
||||
{
|
||||
// Set common name from cert.perm
|
||||
char common_name_value[ClientBaseConstants::COMMON_NAME_LEN] = { 0 };
|
||||
int ret = get_common_name_from_tls_cert(m_certFile.c_str(), common_name_value,
|
||||
ClientBaseConstants::COMMON_NAME_LEN);
|
||||
if (ret != 0) {
|
||||
ERROR("Failed to get common name in: %s", m_certFile.c_str());
|
||||
return -1;
|
||||
}
|
||||
context.AddMetadata("username", std::string(common_name_value, strlen(common_name_value)));
|
||||
context.AddMetadata("tls_mode", m_tlsMode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<sTB> stub_;
|
||||
std::string m_tlsMode { ClientBaseConstants::TLS_OFF };
|
||||
std::string m_certFile { "" };
|
||||
|
||||
@ -230,10 +230,6 @@ public:
|
||||
{
|
||||
int nret = -1;
|
||||
|
||||
if (req.runtime().empty()) {
|
||||
ERROR("Missing runtime in the request");
|
||||
return nret;
|
||||
}
|
||||
if (req.rootfs().empty() && req.image().empty()) {
|
||||
ERROR("Missing container rootfs or image arguments in the request");
|
||||
return nret;
|
||||
@ -1745,7 +1741,13 @@ public:
|
||||
Event event;
|
||||
ClientContext context;
|
||||
Status status;
|
||||
container_events_format_t isula_event;
|
||||
container_events_format_t *isula_event = nullptr;
|
||||
|
||||
if (SetMetadataInfo(context)) {
|
||||
ERROR("Failed to set metadata info for authorization");
|
||||
response->cc = ISULAD_ERR_INPUT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = events_request_to_grpc(request, &req);
|
||||
if (ret != 0) {
|
||||
@ -1756,10 +1758,18 @@ public:
|
||||
|
||||
std::unique_ptr<ClientReader<Event>> reader(stub_->Events(&context, req));
|
||||
while (reader->Read(&event)) {
|
||||
event_from_grpc(&isula_event, &event);
|
||||
if (request->cb != nullptr) {
|
||||
request->cb(&isula_event);
|
||||
isula_event = (container_events_format_t *)util_common_calloc_s(sizeof(container_events_format_t));
|
||||
if (isula_event == nullptr) {
|
||||
ERROR("Out of memory");
|
||||
response->server_errono = ISULAD_ERR_EXEC;
|
||||
return -1;
|
||||
}
|
||||
event_from_grpc(isula_event, &event);
|
||||
if (request->cb != nullptr) {
|
||||
request->cb(isula_event);
|
||||
}
|
||||
container_events_format_free(isula_event);
|
||||
isula_event = nullptr;
|
||||
}
|
||||
status = reader->Finish();
|
||||
if (!status.ok()) {
|
||||
@ -1793,20 +1803,25 @@ private:
|
||||
void event_from_grpc(container_events_format_t *event, Event *gevent)
|
||||
{
|
||||
(void)memset(event, 0, sizeof(*event));
|
||||
if (!gevent->id().empty()) {
|
||||
event->id = (char *)gevent->id().c_str();
|
||||
}
|
||||
|
||||
event->has_type = true;
|
||||
event->type = (container_events_type_t)((int)gevent->type());
|
||||
event->has_pid = (int)gevent->pid() != -1;
|
||||
event->pid = (uint32_t)gevent->pid();
|
||||
event->has_exit_status = true;
|
||||
event->exit_status = gevent->exit_status();
|
||||
|
||||
if (gevent->has_timestamp()) {
|
||||
protobuf_timestamp_from_grpc(&event->timestamp, gevent->timestamp());
|
||||
}
|
||||
|
||||
if (!gevent->opt().empty()) {
|
||||
event->opt = util_strdup_s(gevent->opt().c_str());
|
||||
}
|
||||
|
||||
if (!gevent->id().empty()) {
|
||||
event->id = util_strdup_s(gevent->id().c_str());
|
||||
}
|
||||
|
||||
google::protobuf::Map<std::string, std::string> map = gevent->annotations();
|
||||
for (auto iter = map.cbegin(); iter != map.cend(); ++iter) {
|
||||
std::string anno = iter->first + "=" + iter->second;
|
||||
(void)util_array_append(&event->annotations, anno.c_str());
|
||||
event->annotations_len++;
|
||||
}
|
||||
}
|
||||
|
||||
int events_request_to_grpc(const struct isula_events_request *request, EventsRequest *grequest)
|
||||
|
||||
@ -119,6 +119,7 @@ public:
|
||||
explicit ISulaContainerPrepare(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaContainerPrepare() = default;
|
||||
|
||||
int request_to_grpc(const isula_prepare_request *req, isula::ContainerPrepareRequest *grequest) override
|
||||
{
|
||||
@ -184,6 +185,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~ISulaContainerRemove() = default;
|
||||
|
||||
int request_to_grpc(const isula_remove_request *req, isula::ContainerRemoveRequest *grequest) override
|
||||
{
|
||||
if (req == nullptr) {
|
||||
@ -227,6 +230,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~ISulaContainerMount() = default;
|
||||
|
||||
int request_to_grpc(const isula_mount_request *req, isula::ContainerMountRequest *grequest) override
|
||||
{
|
||||
if (req == nullptr) {
|
||||
@ -270,6 +275,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~ISulaContainerUmount() = default;
|
||||
|
||||
int request_to_grpc(const isula_umount_request *req, isula::ContainerUmountRequest *grequest) override
|
||||
{
|
||||
if (req == nullptr) {
|
||||
@ -314,6 +321,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~ISulaContainersList() = default;
|
||||
|
||||
int request_to_grpc(const isula_containers_list_request *req, isula::ListContainersRequest *grequest) override
|
||||
{
|
||||
if (req == nullptr) {
|
||||
@ -359,6 +368,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~ISulaImagePull() = default;
|
||||
|
||||
int request_to_grpc(const isula_pull_request *req, isula::PullImageRequest *grequest) override
|
||||
{
|
||||
if (req == nullptr) {
|
||||
@ -437,6 +448,7 @@ public:
|
||||
explicit ISulaImageStatus(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaImageStatus() = default;
|
||||
|
||||
int request_to_grpc(const isula_status_request *req, isula::ImageStatusRequest *grequest) override
|
||||
{
|
||||
@ -508,6 +520,7 @@ public:
|
||||
explicit ISulaListImages(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaListImages() = default;
|
||||
|
||||
int request_to_grpc(const isula_list_request *req, isula::ListImagesRequest *grequest) override
|
||||
{
|
||||
@ -574,6 +587,7 @@ public:
|
||||
explicit ISulaRmi(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaRmi() = default;
|
||||
|
||||
int request_to_grpc(const isula_rmi_request *req, isula::RemoveImageRequest *grequest) override
|
||||
{
|
||||
@ -625,6 +639,7 @@ public:
|
||||
explicit ISulaLoad(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaLoad() = default;
|
||||
|
||||
int request_to_grpc(const isula_load_request *req, isula::LoadImageRequest *grequest) override
|
||||
{
|
||||
@ -682,6 +697,7 @@ public:
|
||||
explicit ISulaLogin(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaLogin() = default;
|
||||
|
||||
int request_to_grpc(const isula_login_request *req, isula::LoginRequest *grequest) override
|
||||
{
|
||||
@ -736,6 +752,7 @@ public:
|
||||
explicit ISulaLogout(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaLogout() = default;
|
||||
|
||||
int request_to_grpc(const isula_logout_request *req, isula::LogoutRequest *grequest) override
|
||||
{
|
||||
@ -780,6 +797,7 @@ public:
|
||||
explicit ISulaExport(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaExport() = default;
|
||||
|
||||
int request_to_grpc(const isula_export_request *req, isula::ContainerExportRequest *grequest) override
|
||||
{
|
||||
@ -835,6 +853,7 @@ public:
|
||||
explicit ISulaStorageStatus(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaStorageStatus() = default;
|
||||
|
||||
int response_from_grpc(isula::GraphdriverStatusResponse *gresp, isula_storage_status_response *resp) override
|
||||
{
|
||||
@ -863,6 +882,7 @@ public:
|
||||
explicit ISulaContainerFsUsage(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaContainerFsUsage() = default;
|
||||
|
||||
int request_to_grpc(const isula_container_fs_usage_request *req, isula::ContainerFsUsageRequest *grequest) override
|
||||
{
|
||||
@ -912,6 +932,7 @@ public:
|
||||
explicit ISulaImageFsInfo(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaImageFsInfo() = default;
|
||||
|
||||
int response_from_grpc(isula::ImageFsInfoResponse *gresp, isula_image_fs_info_response *resp) override
|
||||
{
|
||||
@ -993,6 +1014,7 @@ public:
|
||||
explicit ISulaHealthCheck(void *args) : ClientBase(args)
|
||||
{
|
||||
}
|
||||
~ISulaHealthCheck() = default;
|
||||
|
||||
int response_from_grpc(isula::HealthCheckResponse *gresp, isula_health_check_response *resp) override
|
||||
{
|
||||
|
||||
@ -330,7 +330,7 @@ static int unpack_create_response(const struct parsed_http_message *message, voi
|
||||
response->id = util_strdup_s(cresponse->id);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ static int unpack_start_response(const struct parsed_http_message *message, void
|
||||
start_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ static int unpack_list_response(const struct parsed_http_message *message, void
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
if (unpack_container_info_for_list_response(cresponse, response)) {
|
||||
@ -493,7 +493,7 @@ static int unpack_attach_response(const struct parsed_http_message *message, voi
|
||||
attach_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ static int unpack_resume_response(const struct parsed_http_message *message, voi
|
||||
resume_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -562,7 +562,7 @@ static int unpack_wait_response(const struct parsed_http_message *message, void
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ static int unpack_stop_response(const struct parsed_http_message *message, void
|
||||
stop_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -930,7 +930,7 @@ static int unpack_restart_response(const struct parsed_http_message *message, vo
|
||||
response->errmsg = util_strdup_s(cres->errmsg);
|
||||
}
|
||||
ret = (cres->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1043,7 +1043,7 @@ static int unpack_update_response(const struct parsed_http_message *message, voi
|
||||
update_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1150,7 +1150,7 @@ static int unpack_version_response(const struct parsed_http_message *message, vo
|
||||
version_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ static int unpack_pause_response(const struct parsed_http_message *message, void
|
||||
pause_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1349,7 +1349,7 @@ static int unpack_kill_response(const struct parsed_http_message *message, void
|
||||
kill_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1449,7 +1449,7 @@ static int unpack_remove_response(const struct parsed_http_message *message, voi
|
||||
delete_response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1554,7 +1554,7 @@ static int unpack_inspect_response(const struct parsed_http_message *message, vo
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -1704,7 +1704,7 @@ static int unpack_exec_response(const struct parsed_http_message *message, void
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ static int unpack_image_list_response(const struct parsed_http_message *message,
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ static int unpack_image_load_response(const struct parsed_http_message *message,
|
||||
c_load_response->errmsg = util_strdup_s(load_response->errmsg);
|
||||
}
|
||||
ret = (load_response->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ static int unpack_image_delete_response(const struct parsed_http_message *messag
|
||||
c_rmi_response->errmsg = util_strdup_s(delete_response->errmsg);
|
||||
}
|
||||
ret = (delete_response->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ static int unpack_inspect_response(const struct parsed_http_message *message, vo
|
||||
response->errmsg = util_strdup_s(cresponse->errmsg);
|
||||
}
|
||||
ret = (cresponse->cc == ISULAD_SUCCESS) ? 0 : -1;
|
||||
if (message->status_code == EVHTP_RES_SERVERR) {
|
||||
if (message->status_code == RESTFUL_RES_SERVERR) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -41,28 +41,37 @@ void protobuf_timestamp_from_grpc(types_timestamp_t *timestamp, const Timestamp
|
||||
timestamp->nanos = gtimestamp.nanos();
|
||||
}
|
||||
|
||||
void event_to_grpc(const struct isulad_events_format *event, Event *gevent)
|
||||
int event_to_grpc(const struct isulad_events_format *event, Event *gevent)
|
||||
{
|
||||
gevent->Clear();
|
||||
if (event->id != nullptr) {
|
||||
gevent->set_id(event->id);
|
||||
}
|
||||
|
||||
if (event->has_type != 0) {
|
||||
gevent->set_type((EventType)event->type);
|
||||
}
|
||||
if (event->has_pid != 0) {
|
||||
gevent->set_pid((int32_t)(event->pid));
|
||||
} else {
|
||||
gevent->set_pid(-1);
|
||||
}
|
||||
if (event->has_exit_status != 0) {
|
||||
gevent->set_exit_status(event->exit_status);
|
||||
}
|
||||
|
||||
if (event->timestamp.has_seconds != 0 || event->timestamp.has_nanos != 0) {
|
||||
protobuf_timestamp_to_grpc((const types_timestamp_t *)(&event->timestamp), gevent->mutable_timestamp());
|
||||
}
|
||||
|
||||
if (event->opt != nullptr) {
|
||||
gevent->set_opt(event->opt);
|
||||
}
|
||||
|
||||
if (event->id != nullptr) {
|
||||
gevent->set_id(event->id);
|
||||
}
|
||||
|
||||
if (event->annotations_len != 0 && event->annotations != nullptr) {
|
||||
google::protobuf::Map<std::string, std::string> *map = gevent->mutable_annotations();
|
||||
for (size_t i {0}; i < event->annotations_len; i++) {
|
||||
char **elems = util_string_split_n(event->annotations[i], '=', 2);
|
||||
if (util_array_len((const char **)elems) != 2) {
|
||||
ERROR("Invalid annotation info");
|
||||
util_free_array(elems);
|
||||
return -1;
|
||||
}
|
||||
(*map)[elems[0]] = elems[1];
|
||||
util_free_array(elems);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void copy_from_container_response_to_grpc(const struct isulad_copy_from_container_response *copy,
|
||||
@ -93,7 +102,9 @@ bool grpc_event_write_function(void *writer, void *data)
|
||||
struct isulad_events_format *event = (struct isulad_events_format *)data;
|
||||
ServerWriter<Event> *gwriter = (ServerWriter<Event> *)writer;
|
||||
Event gevent;
|
||||
event_to_grpc(event, &gevent);
|
||||
if (event_to_grpc(event, &gevent) != 0) {
|
||||
return false;
|
||||
}
|
||||
return gwriter->Write(gevent);
|
||||
}
|
||||
|
||||
@ -1258,6 +1269,7 @@ Status ContainerServiceImpl::Events(ServerContext *context, const EventsRequest
|
||||
if (ret != 0) {
|
||||
return Status(StatusCode::INTERNAL, "Failed to execute events callback");
|
||||
}
|
||||
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ grpc::Status RuntimeRuntimeServiceImpl::RunPodSandbox(
|
||||
runtime::v1alpha2::RunPodSandboxResponse *reply)
|
||||
{
|
||||
Errors error;
|
||||
std::string responseID = rService.RunPodSandbox(request->config(), error);
|
||||
std::string responseID = rService.RunPodSandbox(request->config(), request->runtime_handler(), error);
|
||||
if (!error.Empty() || responseID.empty()) {
|
||||
return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
|
||||
}
|
||||
|
||||
@ -208,14 +208,14 @@ static void evhtp_send_create_repsponse(evhtp_request_t *req, container_create_r
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate create response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_create_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Create: failed to generate request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -345,14 +345,14 @@ static void evhtp_send_start_repsponse(evhtp_request_t *req, container_start_res
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate start response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_start_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate start request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -373,14 +373,14 @@ static void evhtp_send_list_repsponse(evhtp_request_t *req, container_list_respo
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate inspect response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_list_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate list request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ static void evhtp_send_wait_repsponse(evhtp_request_t *req, container_wait_respo
|
||||
responsedata = container_wait_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate wait request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -424,26 +424,26 @@ static void rest_create_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.create == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceCreate);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.create(crequest, &cresponse);
|
||||
|
||||
evhtp_send_create_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_create_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_create_response(cresponse);
|
||||
free_container_create_request(crequest);
|
||||
@ -459,26 +459,26 @@ static void rest_start_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.start == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceStart);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.start(crequest, &cresponse, -1, NULL, NULL);
|
||||
|
||||
evhtp_send_start_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_start_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_start_request(crequest);
|
||||
free_container_start_response(cresponse);
|
||||
@ -494,26 +494,26 @@ static void rest_wait_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.wait == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceWait);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.wait(crequest, &cresponse);
|
||||
|
||||
evhtp_send_wait_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_wait_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_wait_request(crequest);
|
||||
free_container_wait_response(cresponse);
|
||||
@ -528,14 +528,14 @@ static void evhtp_send_stop_repsponse(evhtp_request_t *req, container_stop_respo
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate stop response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_stop_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate stop request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -557,26 +557,26 @@ static void rest_stop_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.stop == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceStop);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.stop(crequest, &cresponse);
|
||||
|
||||
evhtp_send_stop_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_stop_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_stop_response(cresponse);
|
||||
free_container_stop_request(crequest);
|
||||
@ -591,13 +591,13 @@ static void evhtp_send_restart_response(evhtp_request_t *req, container_restart_
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate restart response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
responsedata = container_restart_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate restart response json: %s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -618,27 +618,27 @@ static void rest_restart_cb(evhtp_request_t *req, void *arg)
|
||||
container_restart_response *cresponse = NULL;
|
||||
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.restart == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceRestart);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.restart(crequest, &cresponse);
|
||||
|
||||
evhtp_send_restart_response(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_restart_response(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_restart_request(crequest);
|
||||
free_container_restart_response(cresponse);
|
||||
@ -654,7 +654,7 @@ static void evhtp_send_version_repsponse(evhtp_request_t *req, container_version
|
||||
responsedata = container_version_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate version request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -676,26 +676,26 @@ static void rest_version_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.version == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceVersion);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.version(crequest, &cresponse);
|
||||
|
||||
evhtp_send_version_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_version_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_version_request(crequest);
|
||||
free_container_version_response(cresponse);
|
||||
@ -710,14 +710,14 @@ static void evhtp_send_update_repsponse(evhtp_request_t *req, container_update_r
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Invalid NULL response");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_update_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate update request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -739,25 +739,25 @@ static void rest_update_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.update == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&container_req, ContainerServiceUpdate);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.update(container_req, &container_res);
|
||||
evhtp_send_update_repsponse(req, container_res, EVHTP_RES_OK);
|
||||
evhtp_send_update_repsponse(req, container_res, RESTFUL_RES_OK);
|
||||
|
||||
out:
|
||||
free_container_update_request(container_req);
|
||||
@ -773,13 +773,13 @@ static void evhtp_send_kill_repsponse(evhtp_request_t *req, container_kill_respo
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate kill response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
responsedata = container_kill_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate kill request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -801,26 +801,26 @@ static void rest_kill_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.kill == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceKill);
|
||||
if (tret < 0) {
|
||||
ERROR("bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.kill(crequest, &cresponse);
|
||||
|
||||
evhtp_send_kill_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_kill_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_kill_request(crequest);
|
||||
free_container_kill_response(cresponse);
|
||||
@ -836,14 +836,14 @@ static void evhtp_send_container_inspect_repsponse(evhtp_request_t *req, contain
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate inspect response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_inspect_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate inspect request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -865,26 +865,26 @@ static void rest_container_inspect_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.inspect == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceInspect);
|
||||
if (tret < 0) {
|
||||
ERROR("bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.inspect(crequest, &cresponse);
|
||||
|
||||
evhtp_send_container_inspect_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_container_inspect_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_inspect_request(crequest);
|
||||
free_container_inspect_response(cresponse);
|
||||
@ -899,14 +899,14 @@ static void evhtp_send_exec_repsponse(evhtp_request_t *req, container_exec_respo
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate exec response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = container_exec_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate exec request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -928,26 +928,26 @@ static void rest_exec_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || !cb->container.exec) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceExec);
|
||||
if (tret < 0) {
|
||||
ERROR("bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.exec(crequest, &cresponse, -1, NULL);
|
||||
|
||||
evhtp_send_exec_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_exec_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_exec_request(crequest);
|
||||
free_container_exec_response(cresponse);
|
||||
@ -962,13 +962,13 @@ static void evhtp_send_remove_repsponse(evhtp_request_t *req, container_delete_r
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate remove response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
responsedata = container_delete_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate remove request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -990,26 +990,26 @@ static void rest_remove_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.remove == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceRemove);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.remove(crequest, &cresponse);
|
||||
|
||||
evhtp_send_remove_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_remove_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_delete_request(crequest);
|
||||
free_container_delete_response(cresponse);
|
||||
@ -1025,26 +1025,26 @@ static void rest_list_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->container.list == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = action_request_from_rest(req, (void **)&crequest, ContainerServiceList);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->container.list(crequest, &cresponse);
|
||||
|
||||
evhtp_send_list_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_list_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_container_list_request(crequest);
|
||||
free_container_list_response(cresponse);
|
||||
|
||||
@ -78,7 +78,7 @@ static void evhtp_send_image_load_repsponse(evhtp_request_t *req,
|
||||
responsedata = image_load_image_response_generate_json(response, NULL, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Load: failed to generate request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
evhtp_send_response(req, responsedata, rescode);
|
||||
@ -126,7 +126,7 @@ static void evhtp_send_image_list_repsponse(evhtp_request_t *req,
|
||||
responsedata = image_list_images_response_generate_json(response, NULL, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("List: failed to generate request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
evhtp_send_response(req, responsedata, rescode);
|
||||
@ -198,7 +198,7 @@ static void evhtp_send_image_delete_repsponse(evhtp_request_t *req,
|
||||
}
|
||||
|
||||
ERROR("Delete: failed to generate request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
out:
|
||||
free(responsedata);
|
||||
free(err);
|
||||
@ -259,14 +259,14 @@ static void evhtp_send_image_inspect_repsponse(evhtp_request_t *req,
|
||||
|
||||
if (response == NULL) {
|
||||
ERROR("Failed to generate inspect response info");
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
responsedata = image_inspect_response_generate_json(response, &ctx, &err);
|
||||
if (responsedata == NULL) {
|
||||
ERROR("Failed to generate inspect request json:%s", err);
|
||||
evhtp_send_reply(req, EVHTP_RES_ERROR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_ERROR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -288,26 +288,26 @@ static void rest_image_load_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->image.load == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = image_load_request_from_rest(req, &crequest);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->image.load(crequest, &cresponse);
|
||||
|
||||
evhtp_send_image_load_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_image_load_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_image_load_image_request(crequest);
|
||||
free_image_load_image_response(cresponse);
|
||||
@ -323,26 +323,26 @@ static void rest_image_list_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->image.list == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = image_list_request_from_rest(req, &crequest);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->image.list(crequest, &cresponse);
|
||||
|
||||
evhtp_send_image_list_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_image_list_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_image_list_images_request(crequest);
|
||||
free_image_list_images_response(cresponse);
|
||||
@ -358,26 +358,26 @@ static void rest_image_delete_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->image.remove == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = image_delete_request_from_rest(req, &crequest);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->image.remove(crequest, &cresponse);
|
||||
|
||||
evhtp_send_image_delete_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_image_delete_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_image_delete_image_request(crequest);
|
||||
free_image_delete_image_response(cresponse);
|
||||
@ -393,26 +393,26 @@ static void rest_image_inspect_cb(evhtp_request_t *req, void *arg)
|
||||
|
||||
// only deal with POST request
|
||||
if (evhtp_request_get_method(req) != htp_method_POST) {
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
cb = get_service_callback();
|
||||
if (cb == NULL || cb->image.inspect == NULL) {
|
||||
ERROR("Unimplemented callback");
|
||||
evhtp_send_reply(req, EVHTP_RES_NOTIMPL);
|
||||
evhtp_send_reply(req, RESTFUL_RES_NOTIMPL);
|
||||
return;
|
||||
}
|
||||
|
||||
tret = image_inspect_request_from_rest(req, &crequest);
|
||||
if (tret < 0) {
|
||||
ERROR("Bad request");
|
||||
evhtp_send_reply(req, EVHTP_RES_SERVERR);
|
||||
evhtp_send_reply(req, RESTFUL_RES_SERVERR);
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)cb->image.inspect(crequest, &cresponse);
|
||||
|
||||
evhtp_send_image_inspect_repsponse(req, cresponse, EVHTP_RES_OK);
|
||||
evhtp_send_image_inspect_repsponse(req, cresponse, RESTFUL_RES_OK);
|
||||
out:
|
||||
free_image_inspect_request(crequest);
|
||||
free_image_inspect_response(cresponse);
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
#include <evhtp.h>
|
||||
|
||||
#include "rest_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -46,6 +46,8 @@
|
||||
|
||||
#define DEBUG_DIRECTORY_MODE 0750
|
||||
|
||||
#define NETWORK_MOUNT_FILE_MODE 0644
|
||||
|
||||
#define ISULAD_CONFIG "/etc/isulad"
|
||||
|
||||
#define ISULAD_DAEMON_JSON_CONF_FILE ISULAD_CONFIG "/daemon.json"
|
||||
|
||||
@ -32,3 +32,27 @@ void container_cgroup_resources_free(container_cgroup_resources_t *cr)
|
||||
free(cr);
|
||||
}
|
||||
|
||||
void container_events_format_free(container_events_format_t *value)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (value == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(value->opt);
|
||||
value->opt = NULL;
|
||||
|
||||
free(value->id);
|
||||
value->id = NULL;
|
||||
|
||||
for (i = 0; i < value->annotations_len; i++) {
|
||||
free(value->annotations[i]);
|
||||
value->annotations[i] = NULL;
|
||||
}
|
||||
|
||||
free(value->annotations);
|
||||
value->annotations = NULL;
|
||||
|
||||
free(value);
|
||||
}
|
||||
@ -40,7 +40,7 @@ extern "C" {
|
||||
#define SECCOMP_DEFAULT_PATH "/etc/isulad/seccomp_default.json"
|
||||
#endif
|
||||
#ifndef OCI_VERSION
|
||||
#define OCI_VERSION "1.0.0-rc5-dev"
|
||||
#define OCI_VERSION "1.0.1"
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
@ -55,12 +55,36 @@ typedef enum {
|
||||
EVENTS_TYPE_THAWED = 8,
|
||||
EVENTS_TYPE_OOM = 9,
|
||||
EVENTS_TYPE_CREATE = 10,
|
||||
EVENTS_TYPE_START = 11,
|
||||
EVENTS_TYPE_EXEC_ADDED = 12,
|
||||
EVENTS_TYPE_PAUSED1 = 13,
|
||||
EVENTS_TYPE_MAX_STATE = 14
|
||||
EVENTS_TYPE_START,
|
||||
EVENTS_TYPE_RESTART,
|
||||
EVENTS_TYPE_STOP,
|
||||
EVENTS_TYPE_EXEC_CREATE,
|
||||
EVENTS_TYPE_EXEC_START,
|
||||
EVENTS_TYPE_EXEC_DIE,
|
||||
EVENTS_TYPE_ATTACH,
|
||||
EVENTS_TYPE_KILL,
|
||||
EVENTS_TYPE_TOP,
|
||||
EVENTS_TYPE_RENAME,
|
||||
EVENTS_TYPE_ARCHIVE_PATH,
|
||||
EVENTS_TYPE_EXTRACT_TO_DIR,
|
||||
EVENTS_TYPE_UPDATE,
|
||||
EVENTS_TYPE_PAUSE,
|
||||
EVENTS_TYPE_UNPAUSE,
|
||||
EVENTS_TYPE_EXPORT,
|
||||
EVENTS_TYPE_RESIZE,
|
||||
EVENTS_TYPE_PAUSED1,
|
||||
EVENTS_TYPE_MAX_STATE
|
||||
} container_events_type_t;
|
||||
|
||||
typedef enum {
|
||||
EVENTS_TYPE_IMAGE_LOAD = 0,
|
||||
EVENTS_TYPE_IMAGE_REMOVE,
|
||||
EVENTS_TYPE_IMAGE_PULL,
|
||||
EVENTS_TYPE_IMAGE_LOGIN,
|
||||
EVENTS_TYPE_IMAGE_LOGOUT,
|
||||
EVENTS_TYPE_IMAGE_MAX_STATE
|
||||
} image_events_type_t;
|
||||
|
||||
typedef enum {
|
||||
CONTAINER_STATUS_UNKNOWN = 0,
|
||||
CONTAINER_STATUS_CREATED = 1,
|
||||
@ -73,10 +97,16 @@ typedef enum {
|
||||
} Container_Status;
|
||||
|
||||
typedef enum {
|
||||
STOPPED, STARTING, RUNNING, STOPPING,
|
||||
ABORTING, FREEZING, FROZEN, THAWED, MAX_STATE
|
||||
EXIT, STOPPED, STARTING, RUNNING, STOPPING, ABORTING, FREEZING,
|
||||
FROZEN, THAWED, OOM, CREATE, START, RESTART, STOP, EXEC_CREATE, EXEC_START, EXEC_DIE, ATTACH,
|
||||
KILL, TOP, RENAME, ARCHIVE_PATH, EXTRACT_TO_DIR, UPDATE, PAUSE, UNPAUSE, EXPORT, RESIZE, PAUSED1, MAX_STATE,
|
||||
} runtime_state_t;
|
||||
|
||||
typedef enum {
|
||||
IM_LOAD, IM_REMOVE, IM_PULL, IM_LOGIN, IM_LOGOUT
|
||||
} image_state_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
HEALTH_SERVING_STATUS_UNKNOWN = 0,
|
||||
HEALTH_SERVING_STATUS_SERVING = 1,
|
||||
@ -100,6 +130,11 @@ typedef enum {
|
||||
WAIT_CONDITION_REMOVED = 1
|
||||
} wait_condition_t;
|
||||
|
||||
typedef enum {
|
||||
CONTAINER_EVENT,
|
||||
IMAGE_EVENT
|
||||
} msg_event_type_t;
|
||||
|
||||
typedef struct container_cgroup_resources {
|
||||
uint16_t blkio_weight;
|
||||
int64_t cpu_shares;
|
||||
@ -116,21 +151,20 @@ typedef struct container_cgroup_resources {
|
||||
int64_t pids_limit;
|
||||
int64_t files_limit;
|
||||
int64_t oom_score_adj;
|
||||
int64_t swappiness;
|
||||
} container_cgroup_resources_t;
|
||||
|
||||
typedef struct container_events_format {
|
||||
char *id;
|
||||
uint32_t has_type;
|
||||
container_events_type_t type;
|
||||
uint32_t has_pid;
|
||||
uint32_t pid;
|
||||
uint32_t has_exit_status;
|
||||
uint32_t exit_status;
|
||||
types_timestamp_t timestamp;
|
||||
char *opt;
|
||||
char *id;
|
||||
char **annotations;
|
||||
char annotations_len;
|
||||
} container_events_format_t;
|
||||
|
||||
void container_cgroup_resources_free(container_cgroup_resources_t *cr);
|
||||
|
||||
void container_events_format_free(container_events_format_t *value);
|
||||
|
||||
typedef void (*container_events_callback_t)(const container_events_format_t *event);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"ociVersion": "1.0.0-rc5-dev",
|
||||
"ociVersion": "1.0.1",
|
||||
"process": {
|
||||
"terminal": true,
|
||||
"consoleSize": {
|
||||
@ -96,18 +96,6 @@
|
||||
"ro"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/dev/shm",
|
||||
"type": "tmpfs",
|
||||
"source": "shm",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"noexec",
|
||||
"nodev",
|
||||
"mode=1777",
|
||||
"size=65536k"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/sys/fs/cgroup",
|
||||
"type": "cgroup",
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"group": "isulad",
|
||||
"default-runtime": "lcr",
|
||||
"graph": "/var/lib/isulad",
|
||||
"state": "/var/run/isulad",
|
||||
"engine": "lcr",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"ociVersion": "1.0.0-rc5-dev",
|
||||
"ociVersion": "1.0.1",
|
||||
"process": {
|
||||
"terminal": true,
|
||||
"consoleSize": {
|
||||
@ -96,18 +96,6 @@
|
||||
"ro"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/dev/shm",
|
||||
"type": "tmpfs",
|
||||
"source": "shm",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"noexec",
|
||||
"nodev",
|
||||
"mode=1777",
|
||||
"size=65536k"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/sys/fs/cgroup",
|
||||
"type": "cgroup",
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@ -552,7 +552,7 @@ char *util_full_file_digest(const char *filename)
|
||||
return full_digest;
|
||||
}
|
||||
|
||||
static char *util_path_dir(const char *path)
|
||||
char *util_path_dir(const char *path)
|
||||
{
|
||||
char *dir = NULL;
|
||||
int len = 0;
|
||||
@ -822,7 +822,7 @@ free_out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int util_write_file(const char *fname, const char *content, size_t content_len)
|
||||
int util_write_file(const char *fname, const char *content, size_t content_len, mode_t mode)
|
||||
{
|
||||
int ret = 0;
|
||||
int dst_fd = -1;
|
||||
@ -834,7 +834,7 @@ int util_write_file(const char *fname, const char *content, size_t content_len)
|
||||
if (content == NULL || content_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
dst_fd = util_open(fname, O_WRONLY | O_CREAT | O_TRUNC, DEFAULT_SECURE_FILE_MODE);
|
||||
dst_fd = util_open(fname, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||
if (dst_fd < 0) {
|
||||
ERROR("Creat file: %s, failed: %s", fname, strerror(errno));
|
||||
ret = -1;
|
||||
@ -877,7 +877,7 @@ char *verify_file_and_get_real_path(const char *file)
|
||||
return util_strdup_s(resolved_path);
|
||||
}
|
||||
|
||||
int util_copy_file(const char *src_file, const char *dst_file)
|
||||
int util_copy_file(const char *src_file, const char *dst_file, mode_t mode)
|
||||
{
|
||||
#define BUFSIZE 4096
|
||||
int ret = 0;
|
||||
@ -902,7 +902,7 @@ int util_copy_file(const char *src_file, const char *dst_file)
|
||||
ret = -1;
|
||||
goto free_out;
|
||||
}
|
||||
dst_fd = util_open(dst_file, O_WRONLY | O_CREAT | O_TRUNC, DEFAULT_SECURE_FILE_MODE);
|
||||
dst_fd = util_open(dst_file, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||
if (dst_fd < 0) {
|
||||
ERROR("Creat file: %s, failed: %s", dst_file, strerror(errno));
|
||||
ret = -1;
|
||||
|
||||
@ -55,6 +55,8 @@ FILE *util_fopen(const char *filename, const char *mode);
|
||||
|
||||
char *util_full_file_digest(const char *filename);
|
||||
|
||||
char *util_path_dir(const char *path);
|
||||
|
||||
char *util_add_path(const char *path, const char *name);
|
||||
|
||||
char *util_read_text_file(const char *path);
|
||||
@ -67,11 +69,11 @@ int util_file2str(const char *filename, char *buf, size_t len);
|
||||
|
||||
char *look_path(const char *file, char **err);
|
||||
|
||||
int util_write_file(const char *fname, const char *content, size_t content_len);
|
||||
int util_write_file(const char *fname, const char *content, size_t content_len, mode_t mode);
|
||||
|
||||
char *verify_file_and_get_real_path(const char *file);
|
||||
|
||||
int util_copy_file(const char *src_file, const char *dst_file);
|
||||
int util_copy_file(const char *src_file, const char *dst_file, mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -79,6 +79,18 @@ bool strings_contains_any(const char *str, const char *substr)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool strings_contains_word(const char *str, const char *substr)
|
||||
{
|
||||
if (str == NULL || substr == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcasestr(str, substr) != NULL) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int strings_count(const char *str, unsigned char c)
|
||||
{
|
||||
size_t i = 0;
|
||||
@ -271,7 +283,8 @@ int util_parse_percent_string(const char *s, long *converted)
|
||||
{
|
||||
char *dup = NULL;
|
||||
|
||||
if (s == NULL || converted == NULL || s[0] == 0 || strlen(s) < 2 || s[strlen(s) - 1] != '%') {
|
||||
if (s == NULL || converted == NULL || s[0] == 0 || strlen(s) < 2 || s[strlen(s) - 1] != '%' ||
|
||||
strspn(s, "0123456789%") != strlen(s)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
dup = util_strdup_s(s);
|
||||
@ -282,7 +295,7 @@ int util_parse_percent_string(const char *s, long *converted)
|
||||
|
||||
*converted = strtol(dup, NULL, 10);
|
||||
if ((errno == ERANGE && (*converted == LONG_MAX || *converted == LONG_MIN)) ||
|
||||
(errno != 0 && *converted == 0) || *converted < 0 || *converted >= 100) {
|
||||
(errno != 0 && *converted == 0) || *converted < 0 || *converted > 100) {
|
||||
free(dup);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -369,6 +382,49 @@ err_out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char **util_string_split_n(const char *src, char sep, size_t n)
|
||||
{
|
||||
char **res_array = NULL;
|
||||
const char *index = NULL;
|
||||
char *token = NULL;
|
||||
char *str = NULL;
|
||||
size_t count = 0;
|
||||
int tmp_errno;
|
||||
|
||||
if (src == NULL || n == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (src[0] == '\0') {
|
||||
return make_empty_array();
|
||||
}
|
||||
str = util_strdup_s(src);
|
||||
index = str;
|
||||
for (token = strchr(index, sep); token != NULL; token = strchr(index, sep)) {
|
||||
count++;
|
||||
if (count >= n) {
|
||||
break;
|
||||
}
|
||||
*token = '\0';
|
||||
if (util_array_append(&res_array, index) != 0) {
|
||||
goto err_out;
|
||||
}
|
||||
index = token + 1;
|
||||
}
|
||||
if (util_array_append(&res_array, index) != 0) {
|
||||
goto err_out;
|
||||
}
|
||||
free(str);
|
||||
return res_array;
|
||||
|
||||
err_out:
|
||||
tmp_errno = errno;
|
||||
free(str);
|
||||
util_free_array(res_array);
|
||||
errno = tmp_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char **util_string_split(const char *src_str, char _sep)
|
||||
{
|
||||
char *token = NULL;
|
||||
|
||||
@ -25,6 +25,8 @@ extern "C" {
|
||||
|
||||
bool strings_contains_any(const char *str, const char *substr);
|
||||
|
||||
bool strings_contains_word(const char *str, const char *substr);
|
||||
|
||||
int strings_count(const char *str, unsigned char c);
|
||||
|
||||
bool strings_in_slice(const char **strarray, size_t alen, const char *str);
|
||||
@ -45,6 +47,8 @@ char **util_string_split(const char *src_str, char _sep);
|
||||
// note that every delimiter bytes is considered to be a single delimiter
|
||||
char **util_string_split_multi(const char *src_str, char delim);
|
||||
|
||||
char **util_string_split_n(const char *src_str, char delim, size_t n);
|
||||
|
||||
const char *str_skip_str(const char *str, const char *skip);
|
||||
|
||||
char *util_string_delchar(const char *ss, unsigned char c);
|
||||
|
||||
@ -274,7 +274,7 @@ bool util_valid_runtime_name(const char *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
return strcasecmp(name, "lcr") == 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool util_valid_host_name(const char *name)
|
||||
@ -386,7 +386,7 @@ cleanup:
|
||||
|
||||
bool util_valid_time_tz(const char *time)
|
||||
{
|
||||
char *patten = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2,9})?Z$";
|
||||
char *patten = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2,9})?(Z|[+-][0-9]{2}:[0-9]{2})$";
|
||||
|
||||
if (time == NULL) {
|
||||
ERROR("invalid NULL param");
|
||||
|
||||
@ -16,7 +16,7 @@ target_include_directories(libhttpclient PUBLIC
|
||||
|
||||
# set libhttpclient FLAGS
|
||||
set_target_properties(libhttpclient PROPERTIES PREFIX "")
|
||||
target_link_libraries(libhttpclient ${HTTP_PARSER_LIBRARY} ${CURL_LIBRARY} ${LIBSECUREC_LIBRARY})
|
||||
target_link_libraries(libhttpclient ${HTTP_PARSER_LIBRARY} ${CURL_LIBRARY})
|
||||
|
||||
if (ISULAD_GCOV)
|
||||
target_link_libraries(libhttpclient -lgcov)
|
||||
|
||||
@ -52,15 +52,15 @@ static int g_ops_status = 0;
|
||||
/* check status code */
|
||||
int check_status_code(int status_code)
|
||||
{
|
||||
if (status_code == EVHTP_RES_OK || status_code == EVHTP_RES_SERVERR) {
|
||||
if (status_code == RESTFUL_RES_OK || status_code == RESTFUL_RES_SERVERR) {
|
||||
return 0;
|
||||
} else if (status_code == EVHTP_RES_NOTIMPL) {
|
||||
} else if (status_code == RESTFUL_RES_NOTIMPL) {
|
||||
ERROR("Not implement interface");
|
||||
return -1;
|
||||
} else if (status_code == EVHTP_RES_NOTFOUND) {
|
||||
} else if (status_code == RESTFUL_RES_NOTFOUND) {
|
||||
ERROR("Can not connect to service");
|
||||
return -1;
|
||||
} else if (status_code == EVHTP_RES_ERROR) {
|
||||
} else if (status_code == RESTFUL_RES_ERROR) {
|
||||
ERROR("Server internal error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -15,8 +15,6 @@
|
||||
#ifndef __REST_COMMON_H
|
||||
#define __REST_COMMON_H
|
||||
|
||||
#include <evhtp.h>
|
||||
|
||||
#include "http/buffer.h"
|
||||
#include "http/http.h"
|
||||
#include "parser.h"
|
||||
@ -25,6 +23,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Response status from restful server
|
||||
#define RESTFUL_RES_ERROR 0
|
||||
#define RESTFUL_RES_OK 200
|
||||
#define RESTFUL_RES_NOTFOUND 404
|
||||
#define RESTFUL_RES_SERVERR 500
|
||||
#define RESTFUL_RES_NOTIMPL 501
|
||||
|
||||
typedef int (*unpack_response_func_t)(const struct parsed_http_message *message, void *arg);
|
||||
|
||||
int get_response(Buffer *output, unpack_response_func_t unpack_func, void *arg);
|
||||
|
||||
@ -382,12 +382,6 @@ static bool validate_create_time(char *created)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ensure time can be processed by us */
|
||||
if (time_tz_to_seconds_nanos(created, NULL, NULL)) {
|
||||
ERROR("invalid created time %s, invalid time value", created);
|
||||
isulad_try_set_error_message("Invalid content in manifest: invalid created time");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include "ext_image.h"
|
||||
#include "filters.h"
|
||||
#include "collector.h"
|
||||
|
||||
#ifdef ENABLE_OCI_IMAGE
|
||||
#include "isula_image.h"
|
||||
@ -163,6 +164,10 @@ static const struct bim_type *bim_query(const char *image_name)
|
||||
WARN("Unimplements resolve image name in %s", g_bims[i].image_type);
|
||||
continue;
|
||||
}
|
||||
if (g_bims[i].ops->detect == NULL) {
|
||||
WARN("Unimplements detect in %s", g_bims[i].image_type);
|
||||
continue;
|
||||
}
|
||||
temp = g_bims[i].ops->resolve_image_name(image_name);
|
||||
if (temp == NULL) {
|
||||
isulad_append_error_message("Failed to resovle image name%s", image_name);
|
||||
@ -236,6 +241,12 @@ static struct bim *bim_get(const char *image_type, const char *image_name, const
|
||||
bim->ops = q->ops;
|
||||
bim->type = q->image_type;
|
||||
|
||||
if (bim->ops->resolve_image_name == NULL) {
|
||||
ERROR("Unimplements resolve image name");
|
||||
bim_put(bim);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (image_name != NULL) {
|
||||
bim->image_name = bim->ops->resolve_image_name(image_name);
|
||||
if (bim->image_name == NULL) {
|
||||
@ -919,6 +930,7 @@ int im_pull_image(const im_pull_request *request, im_pull_response **response)
|
||||
goto out;
|
||||
}
|
||||
EVENT("Event: {Object: %s, Type: Pulled}", request->image);
|
||||
(void)isulad_monitor_send_image_event(request->image, IM_PULL);
|
||||
|
||||
out:
|
||||
bim_put(bim);
|
||||
@ -1049,13 +1061,40 @@ void free_im_load_response(im_load_response *ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static bool check_login_request(const im_login_request *request)
|
||||
{
|
||||
if (request == NULL) {
|
||||
ERROR("Invalid input arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request->server == NULL) {
|
||||
ERROR("Login requires server address");
|
||||
isulad_set_error_message("Login requires server address");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request->type == NULL) {
|
||||
ERROR("Login requires image type");
|
||||
isulad_set_error_message("Login requires image type");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request->username == NULL || request->password == NULL) {
|
||||
ERROR("Missing username or password");
|
||||
isulad_set_error_message("Missing username or password");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int im_login(const im_login_request *request, im_login_response **response)
|
||||
{
|
||||
int ret = -1;
|
||||
struct bim *bim = NULL;
|
||||
|
||||
if (request == NULL || response == NULL) {
|
||||
ERROR("Invalid input arguments");
|
||||
if (response == NULL) {
|
||||
ERROR("Empty response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1065,21 +1104,7 @@ int im_login(const im_login_request *request, im_login_response **response)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (request->server == NULL) {
|
||||
ERROR("Login requires server address");
|
||||
isulad_set_error_message("Login requires server address");
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
if (request->type == NULL) {
|
||||
ERROR("Login requires image type");
|
||||
isulad_set_error_message("Login requires image type");
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
if (request->username == NULL || request->password == NULL) {
|
||||
ERROR("Missing username or password");
|
||||
isulad_set_error_message("Missing username or password");
|
||||
if (!check_login_request(request)) {
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
@ -1089,6 +1114,11 @@ int im_login(const im_login_request *request, im_login_response **response)
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
if (bim->ops->login == NULL) {
|
||||
ERROR("Unimplements login in %s", bim->type);
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
EVENT("Event: {Object: %s, Type: logining}", request->server);
|
||||
|
||||
ret = bim->ops->login(request);
|
||||
@ -1142,13 +1172,34 @@ void free_im_login_response(im_login_response *ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static bool check_logout_request(const im_logout_request *request)
|
||||
{
|
||||
if (request == NULL) {
|
||||
ERROR("Invalid input arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request->server == NULL) {
|
||||
ERROR("Logout requires server address");
|
||||
isulad_set_error_message("Logout requires server address");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request->type == NULL) {
|
||||
ERROR("Logout requires image type");
|
||||
isulad_set_error_message("Logout requires image type");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int im_logout(const im_logout_request *request, im_logout_response **response)
|
||||
{
|
||||
int ret = -1;
|
||||
struct bim *bim = NULL;
|
||||
|
||||
if (request == NULL || response == NULL) {
|
||||
ERROR("Invalid input arguments");
|
||||
if (response == NULL) {
|
||||
ERROR("Empty response");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1158,15 +1209,7 @@ int im_logout(const im_logout_request *request, im_logout_response **response)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (request->server == NULL) {
|
||||
ERROR("Logout requires server address");
|
||||
isulad_set_error_message("Logout requires server address");
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
if (request->type == NULL) {
|
||||
ERROR("Logout requires image type");
|
||||
isulad_set_error_message("Logout requires image type");
|
||||
if (!check_logout_request(request)) {
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
@ -1176,6 +1219,11 @@ int im_logout(const im_logout_request *request, im_logout_response **response)
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
if (bim->ops->logout == NULL) {
|
||||
ERROR("Unimplements logout in %s", bim->type);
|
||||
goto pack_response;
|
||||
}
|
||||
|
||||
EVENT("Event: {Object: %s, Type: logouting}", request->server);
|
||||
|
||||
ret = bim->ops->logout(request);
|
||||
@ -1335,6 +1383,7 @@ int im_rm_image(const im_remove_request *request, im_remove_response **response)
|
||||
}
|
||||
|
||||
EVENT("Event: {Object: %s, Type: image removed}", image_ref);
|
||||
(void)isulad_monitor_send_image_event(image_ref, IM_REMOVE);
|
||||
|
||||
pack_response:
|
||||
if (g_isulad_errmsg != NULL) {
|
||||
@ -1616,6 +1665,10 @@ static int bims_init(const struct im_configs *conf)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < g_numbims; i++) {
|
||||
if (g_bims[i].ops->init == NULL) {
|
||||
WARN("Unimplements init in %s", g_bims[i].image_type);
|
||||
continue;
|
||||
}
|
||||
ret = g_bims[i].ops->init(conf);
|
||||
if (ret != 0) {
|
||||
ERROR("Failed to init bim %s", g_bims[i].image_type);
|
||||
@ -1759,4 +1812,3 @@ void im_sync_containers_isuladkit(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -382,4 +382,3 @@ void im_sync_containers_isuladkit(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ int isula_image_fs_info(im_fs_info_response *resp)
|
||||
struct isula_image_fs_info_request ireq = {0};
|
||||
struct isula_image_fs_info_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
if (resp == NULL) {
|
||||
ERROR("Invalid arguments");
|
||||
|
||||
@ -103,7 +103,7 @@ static int isula_pull_response_to_im(const struct isula_pull_response *iresp, im
|
||||
|
||||
int isula_pull_image(const im_pull_request *request, im_pull_response **response)
|
||||
{
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
struct isula_pull_request *ireq = NULL;
|
||||
struct isula_pull_response *iresp = NULL;
|
||||
int ret = -1;
|
||||
|
||||
@ -56,7 +56,7 @@ int isula_image_rmi(const char *image, bool force, char **errmsg)
|
||||
struct isula_rmi_request *ireq = NULL;
|
||||
struct isula_rmi_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
im_ops = get_isula_image_ops();
|
||||
if (im_ops == NULL) {
|
||||
|
||||
@ -111,7 +111,7 @@ imagetool_image *isula_image_get_image_info_by_name(const char *image_name)
|
||||
struct isula_status_request *ireq = NULL;
|
||||
struct isula_status_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
imagetool_image *result = NULL;
|
||||
int ret = -1;
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ int isula_list_images(const im_list_request *request, imagetool_images_list **im
|
||||
struct isula_list_request *ireq = NULL;
|
||||
struct isula_list_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
int ret = -1;
|
||||
|
||||
im_ops = get_isula_image_ops();
|
||||
|
||||
@ -61,7 +61,7 @@ int isula_do_login(const char *server, const char *username, const char *passwor
|
||||
struct isula_login_request *ireq = NULL;
|
||||
struct isula_login_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
if (is_valid_arguments(server, username, password) != 0) {
|
||||
ERROR("Invalid arguments");
|
||||
|
||||
@ -45,7 +45,7 @@ int isula_rootfs_mount(const char *name_id)
|
||||
struct isula_mount_request *ireq = NULL;
|
||||
struct isula_mount_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
im_ops = get_isula_image_ops();
|
||||
if (im_ops == NULL) {
|
||||
|
||||
@ -47,7 +47,7 @@ int isula_rootfs_remove(const char *name_id)
|
||||
struct isula_remove_request *ireq = NULL;
|
||||
struct isula_remove_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
im_ops = get_isula_image_ops();
|
||||
if (im_ops == NULL) {
|
||||
|
||||
@ -41,6 +41,21 @@ static int generate_isula_umount_request(const char *name_id, bool force, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool is_container_nonexist_error(const struct isula_umount_response *iresp)
|
||||
{
|
||||
#define CONTAINER_NOT_KNOWN_ERR "container not known"
|
||||
if (iresp == NULL || iresp->errmsg == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstr(iresp->errmsg, CONTAINER_NOT_KNOWN_ERR) != NULL) {
|
||||
DEBUG("Container may already removed");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int isula_rootfs_umount(const char *name_id, bool force)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -48,7 +63,7 @@ int isula_rootfs_umount(const char *name_id, bool force)
|
||||
struct isula_umount_request *ireq = NULL;
|
||||
struct isula_umount_response *iresp = NULL;
|
||||
client_connect_config_t conf = { 0 };
|
||||
isula_image_ops *im_ops;
|
||||
isula_image_ops *im_ops = NULL;
|
||||
|
||||
im_ops = get_isula_image_ops();
|
||||
if (im_ops == NULL) {
|
||||
@ -81,7 +96,7 @@ int isula_rootfs_umount(const char *name_id, bool force)
|
||||
|
||||
INFO("Send umount rootfs GRPC request");
|
||||
nret = im_ops->umount(ireq, iresp, &conf);
|
||||
if (nret != 0) {
|
||||
if (nret != 0 && !is_container_nonexist_error(iresp)) {
|
||||
ERROR("Remove rootfs %s failed: %s", name_id, iresp != NULL ? iresp->errmsg : "null");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
@ -97,8 +97,6 @@ static int oci_image_merge_env(const oci_image_spec_config *config, container_co
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_duplicate_commands(const oci_image_spec_config *config, container_config *container_spec)
|
||||
@ -172,6 +170,44 @@ static int oci_image_merge_entrypoint(const oci_image_spec_config *config, conta
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int make_sure_container_config_labels(container_config *container_spec)
|
||||
{
|
||||
if (container_spec->labels != NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
container_spec->labels = util_common_calloc_s(sizeof(json_map_string_string));
|
||||
if (container_spec->labels == NULL) {
|
||||
ERROR("Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int oci_image_merge_labels(const oci_image_spec_config *config, container_config *container_spec)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (config->labels == NULL || config->labels->len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (make_sure_container_config_labels(container_spec) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < config->labels->len; i++) {
|
||||
int ret = append_json_map_string_string(container_spec->labels,
|
||||
config->labels->keys[i], config->labels->values[i]);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void oci_image_merge_user(const char *user, container_config *container_spec)
|
||||
{
|
||||
if (container_spec->user != NULL) {
|
||||
@ -314,6 +350,11 @@ int oci_image_merge_config(imagetool_image *image_conf, container_config *contai
|
||||
|
||||
oci_image_merge_user(image_conf->spec->config->user, container_spec);
|
||||
|
||||
if (oci_image_merge_labels(image_conf->spec->config, container_spec) != 0) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// ignore volumes now
|
||||
}
|
||||
|
||||
|
||||
@ -18,8 +18,16 @@
|
||||
|
||||
# include "oci_runtime_spec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
oci_runtime_spec_hooks *oci_runtime_spec_hooks_parse_file(const char *filename,
|
||||
const struct parser_context *ctx, parser_error *err);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -40,6 +40,9 @@
|
||||
"ResolvConfPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"ShmPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"LogPath": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -91,6 +94,18 @@
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"MountLabel": {
|
||||
"type": "string"
|
||||
},
|
||||
"ProcessLabel": {
|
||||
"type": "string"
|
||||
},
|
||||
"SeccompProfile": {
|
||||
"type": "string"
|
||||
},
|
||||
"NoNewPrivileges": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
15
src/json/schema/schema/container/get-runtime-response.json
Normal file
15
src/json/schema/schema/container/get-runtime-response.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"runtime": {
|
||||
"type": "string"
|
||||
},
|
||||
"cc": {
|
||||
"type": "uint32"
|
||||
},
|
||||
"errmsg": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,6 +75,18 @@
|
||||
"RestartCount":{
|
||||
"type":"integer"
|
||||
},
|
||||
"MountLabel":{
|
||||
"type":"string"
|
||||
},
|
||||
"ProcessLabel":{
|
||||
"type":"string"
|
||||
},
|
||||
"SeccompProfile": {
|
||||
"type": "string"
|
||||
},
|
||||
"NoNewPrivileges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"HostConfig":{
|
||||
"$ref": "../host-config.json"
|
||||
},
|
||||
|
||||
@ -232,6 +232,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"mapStringObjectRuntimes": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
".{1,}": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtime-args": {
|
||||
"type":"array",
|
||||
"items": {
|
||||
"type":"string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ociVersion": {
|
||||
"description": "The version of Open Container Runtime Specification that the document complies with",
|
||||
"type": "string"
|
||||
|
||||
@ -213,6 +213,9 @@
|
||||
"MemorySwap": {
|
||||
"type": "int64"
|
||||
},
|
||||
"MemorySwappiness": {
|
||||
"$ref": "defs.json#/definitions/uint64Pointer"
|
||||
},
|
||||
"OomKillDisable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
@ -5,6 +5,9 @@
|
||||
"hosts": {
|
||||
"type": "ArrayOfStrings"
|
||||
},
|
||||
"default-runtime": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -144,6 +147,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"runtimes": {
|
||||
"$ref": "defs.json#/definitions/mapStringObjectRuntimes"
|
||||
},
|
||||
"selinux-enabled" : {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
193
src/json/schema/schema/shim/client/process-state.json
Normal file
193
src/json/schema/schema/shim/client/process-state.json
Normal file
@ -0,0 +1,193 @@
|
||||
{
|
||||
"description": "process state info",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"cwd",
|
||||
"args"
|
||||
],
|
||||
"properties": {
|
||||
"args": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/args",
|
||||
"$ref": "../../defs.json#/definitions/ArrayOfStrings"
|
||||
},
|
||||
"consoleSize": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/consoleSize",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"height",
|
||||
"width"
|
||||
],
|
||||
"properties": {
|
||||
"height": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/consoleSize/height",
|
||||
"$ref": "../../defs.json#/definitions/uint64"
|
||||
},
|
||||
"width": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/consoleSize/width",
|
||||
"$ref": "../../defs.json#/definitions/uint64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"cwd": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/cwd",
|
||||
"type": "string"
|
||||
},
|
||||
"env": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/env",
|
||||
"$ref": "../../defs.json#/definitions/Env"
|
||||
},
|
||||
"terminal": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/terminal",
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/user",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"uid": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/user/uid",
|
||||
"$ref": "../../defs.json#/definitions/UID"
|
||||
},
|
||||
"gid": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/user/gid",
|
||||
"$ref": "../../defs.json#/definitions/GID"
|
||||
},
|
||||
"additionalGids": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/user/additionalGids",
|
||||
"$ref": "../../defs.json#/definitions/ArrayOfGIDs"
|
||||
},
|
||||
"username": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/user/username",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"capabilities": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bounding": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/bounding",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"permitted": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/permitted",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"effective": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/effective",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"inheritable": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/inheritable",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"ambient": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"apparmorProfile": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/apparmorProfile",
|
||||
"type": "string"
|
||||
},
|
||||
"oomScoreAdj": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/oomScoreAdj",
|
||||
"type": "integer"
|
||||
},
|
||||
"selinuxLabel": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/selinuxLabel",
|
||||
"type": "string"
|
||||
},
|
||||
"noNewPrivileges": {
|
||||
"id": "https://opencontainers.org/schema/bundle/process/linux/noNewPrivileges",
|
||||
"type": "boolean"
|
||||
},
|
||||
"rlimits": {
|
||||
"id": "https://opencontainers.org/schema/bundle/linux/rlimits",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"soft",
|
||||
"hard"
|
||||
],
|
||||
"properties": {
|
||||
"hard": {
|
||||
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/hard",
|
||||
"$ref": "../../defs.json#/definitions/uint64"
|
||||
},
|
||||
"soft": {
|
||||
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/soft",
|
||||
"$ref": "../../defs.json#/definitions/uint64"
|
||||
},
|
||||
"type": {
|
||||
"id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/type",
|
||||
"type": "string",
|
||||
"pattern": "^RLIMIT_[A-Z]+$"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"exit_fifo": {
|
||||
"type": "string"
|
||||
},
|
||||
"control_fifo": {
|
||||
"type": "string"
|
||||
},
|
||||
"exec": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"open_tty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"open_stdin": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isuladStdin": {
|
||||
"type": "string"
|
||||
},
|
||||
"isuladStdout": {
|
||||
"type": "string"
|
||||
},
|
||||
"isuladStderr": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtimeArgs": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"noPivotRoot": {
|
||||
"tyoe": "boolean"
|
||||
},
|
||||
"checkpoint": {
|
||||
"type": "string"
|
||||
},
|
||||
"rootUID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"rootGID": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user