diff --git a/iSulad.spec b/iSulad.spec index 5b09f53..9ddd359 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 1.1.9 -%global _release 20200121.100120.gite61a5e35 +%global _release 20200206.104209.gitd282adb9 %global is_systemd 1 %global debug_package %{nil} diff --git a/src/cmd/isula/commands.c b/src/cmd/isula/commands.c index d1bc433..558427e 100644 --- a/src/cmd/isula/commands.c +++ b/src/cmd/isula/commands.c @@ -47,6 +47,7 @@ static void send_msg_to_syslog(int argc, const char **argv) for (; target_command[i] != NULL; i++) { if (strcmp(argv[1], target_command[i]) == 0) { found = true; + break; } } if (!found) { diff --git a/src/cmd/isula/main.c b/src/cmd/isula/main.c index a7b94ea..3da0621 100644 --- a/src/cmd/isula/main.c +++ b/src/cmd/isula/main.c @@ -134,7 +134,7 @@ struct command g_commands[] = { "wait", cmd_wait_main, g_cmd_wait_desc, NULL, &g_cmd_wait_args }, { - // `wait` sub-command + // `logs` sub-command "logs", cmd_logs_main, g_cmd_logs_desc, NULL, &g_cmd_logs_args }, #endif diff --git a/src/cmd/isulad/arguments.c b/src/cmd/isulad/arguments.c index d4cab30..7381a87 100644 --- a/src/cmd/isulad/arguments.c +++ b/src/cmd/isulad/arguments.c @@ -156,6 +156,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; ret = 0; diff --git a/src/cmd/isulad/arguments.h b/src/cmd/isulad/arguments.h index 9df04e7..0833457 100644 --- a/src/cmd/isulad/arguments.h +++ b/src/cmd/isulad/arguments.h @@ -57,6 +57,7 @@ struct service_arguments { /* default configs */ host_config_ulimits_element **default_ulimit; size_t default_ulimit_len; + unsigned int websocket_server_listening_port; // remaining arguments char * const *argv; diff --git a/src/cmd/isulad/commands.c b/src/cmd/isulad/commands.c index 6f72948..7873027 100644 --- a/src/cmd/isulad/commands.c +++ b/src/cmd/isulad/commands.c @@ -228,6 +228,27 @@ out: return ret; } +static int check_websocket_server_listening_port(const struct service_arguments *args) +{ +#define MIN_REGISTER_PORT 1024 +#define MAX_REGISTER_PORT 49151 + int ret = 0; + + if (args->json_confs->websocket_server_listening_port < MIN_REGISTER_PORT || + args->json_confs->websocket_server_listening_port > MAX_REGISTER_PORT) { + COMMAND_ERROR("Invalid websocket server listening port: '%d' (range: %d-%d)", + args->json_confs->websocket_server_listening_port, + MIN_REGISTER_PORT, MAX_REGISTER_PORT); + ERROR("Invalid websocket server listening port: '%d' (range: %d-%d)", + args->json_confs->websocket_server_listening_port, + MIN_REGISTER_PORT, MAX_REGISTER_PORT); + ret = -1; + goto out; + } +out: + return ret; +} + int check_args(struct service_arguments *args) { int ret = 0; @@ -291,6 +312,11 @@ int check_args(struct service_arguments *args) goto out; } + if (check_websocket_server_listening_port(args) != 0) { + ret = -1; + goto out; + } + out: return ret; } diff --git a/src/cmd/isulad/commands.h b/src/cmd/isulad/commands.h index ce1d203..d09037e 100644 --- a/src/cmd/isulad/commands.h +++ b/src/cmd/isulad/commands.h @@ -99,7 +99,10 @@ int update_default_ulimit(struct service_arguments *args); { CMD_OPT_TYPE_STRING_DUP, false, "tlskey", 0, &(cmdargs)->json_confs->tls_config->key_file, \ "Path to TLS key file (default \"/root/.iSulad/key.pem\")", NULL }, \ { CMD_OPT_TYPE_CALLBACK, false, "default-ulimit", 0, &(cmdargs)->default_ulimit, \ - "Default ulimits for containers (default [])", command_default_ulimit_append } + "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 } #endif /* __COMMAND_H */ diff --git a/src/config/isulad_config.c b/src/config/isulad_config.c index 47cf093..fbd0080 100644 --- a/src/config/isulad_config.c +++ b/src/config/isulad_config.c @@ -1256,6 +1256,28 @@ out: return plugins; } +/* conf get websocket server listening port */ +int32_t conf_get_websocket_server_listening_port() +{ + int32_t port = 0; + struct service_arguments *conf = NULL; + + if (isulad_server_conf_rdlock() != 0) { + return port; + } + + conf = conf_get_server_conf(); + if (conf == NULL) { + goto out; + } + + port = conf->json_confs->websocket_server_listening_port; + +out: + (void)isulad_server_conf_unlock(); + return port; +} + /* save args to conf */ int save_args_to_conf(struct service_arguments *args) { @@ -1794,6 +1816,10 @@ int merge_json_confs_into_global(struct service_arguments *args) args->json_confs->image_layer_check = tmp_json_confs->image_layer_check; } + if (tmp_json_confs->websocket_server_listening_port) { + args->json_confs->websocket_server_listening_port = tmp_json_confs->websocket_server_listening_port; + } + override_bool_pointer_value(&args->json_confs->use_decrypted_key, &tmp_json_confs->use_decrypted_key); if (tmp_json_confs->insecure_skip_verify_enforce) { diff --git a/src/config/isulad_config.h b/src/config/isulad_config.h index 492e730..58ce068 100644 --- a/src/config/isulad_config.h +++ b/src/config/isulad_config.h @@ -47,6 +47,7 @@ char *conf_get_isulad_log_gather_fifo_path(); char *conf_get_isulad_log_file(); char *conf_get_engine_log_file(); char *conf_get_enable_plugins(); +int32_t conf_get_websocket_server_listening_port(); int save_args_to_conf(struct service_arguments *args); diff --git a/src/constants.h b/src/constants.h index 624c1f9..bbc033d 100644 --- a/src/constants.h +++ b/src/constants.h @@ -59,5 +59,7 @@ #define MAX_MSG_BUFFER_SIZE (32 * 1024) +#define DEFAULT_WEBSOCKET_SERVER_LISTENING_PORT 10350 + #endif diff --git a/src/json/schema/schema/isulad-daemon-configs.json b/src/json/schema/schema/isulad-daemon-configs.json index ca04ffa..eb289c0 100644 --- a/src/json/schema/schema/isulad-daemon-configs.json +++ b/src/json/schema/schema/isulad-daemon-configs.json @@ -118,6 +118,9 @@ "cgroup-parent": { "type": "string" }, + "websocket-server-listening-port": { + "type": "int32" + }, "default-ulimits": { "type": "object", "patternProperties": { diff --git a/src/json/schema/src/common_c.py b/src/json/schema/src/common_c.py index 4ccf16b..239440a 100644 --- a/src/json/schema/src/common_c.py +++ b/src/json/schema/src/common_c.py @@ -22,6 +22,16 @@ History: 2019-06-17 # # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . +# +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. CODE = '''// Auto generated file. Do not edit! # define _GNU_SOURCE diff --git a/src/json/schema/src/common_h.py b/src/json/schema/src/common_h.py index c1a8a8b..8baafbe 100644 --- a/src/json/schema/src/common_h.py +++ b/src/json/schema/src/common_h.py @@ -23,6 +23,15 @@ History: 2019-06-17 # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . # +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. #!/usr/bin/python -Es """ diff --git a/src/json/schema/src/generate.py b/src/json/schema/src/generate.py index 534e07e..698262c 100644 --- a/src/json/schema/src/generate.py +++ b/src/json/schema/src/generate.py @@ -22,6 +22,16 @@ History: 2019-06-17 # # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . +# +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. import traceback import os diff --git a/src/json/schema/src/headers.py b/src/json/schema/src/headers.py index 98116a6..e35d24c 100644 --- a/src/json/schema/src/headers.py +++ b/src/json/schema/src/headers.py @@ -23,6 +23,16 @@ History: 2019-06-17 # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . # +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. +# #!/usr/bin/python -Es import helpers diff --git a/src/json/schema/src/helpers.py b/src/json/schema/src/helpers.py index 92a96c9..cb344c6 100644 --- a/src/json/schema/src/helpers.py +++ b/src/json/schema/src/helpers.py @@ -23,6 +23,15 @@ History: 2019-06-17 # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . # +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. #!/usr/bin/python -Es import os import sys diff --git a/src/json/schema/src/sources.py b/src/json/schema/src/sources.py index d4b5393..3b5d9a1 100644 --- a/src/json/schema/src/sources.py +++ b/src/json/schema/src/sources.py @@ -19,6 +19,15 @@ # You should have received a copy of the GNU General Public License # along with libocispec. If not, see . # +# As a special exception, you may create a larger work that contains +# part or all of the libocispec parser skeleton and distribute that work +# under terms of your choice, so long as that work isn't itself a +# parser generator using the skeleton or a modified version thereof +# as a parser skeleton. Alternatively, if you modify or redistribute +# the parser skeleton itself, you may (at your option) remove this +# special exception, which will cause the skeleton and the resulting +# libocispec output files to be licensed under the GNU General Public +# License without this special exception. import helpers diff --git a/src/websocket/service/ws_server.cc b/src/websocket/service/ws_server.cc index 8c42aa8..8a3624f 100644 --- a/src/websocket/service/ws_server.cc +++ b/src/websocket/service/ws_server.cc @@ -24,6 +24,7 @@ #include "utils.h" #include "request_cache.h" #include "constants.h" +#include "isulad_config.h" struct lws_context *WebsocketServer::m_context = nullptr; std::atomic WebsocketServer::m_instance; @@ -385,6 +386,12 @@ void WebsocketServer::ServiceWorkThread(int threadid) void WebsocketServer::Start(Errors &err) { + m_listenPort = conf_get_websocket_server_listening_port(); + if (m_listenPort == 0) { + err.SetError("Failed to get websocket server listening port from daemon config"); + return; + } + if (CreateContext() < 0) { err.SetError("Websocket server start failed!, please check your network status" "(eg: port " + std::to_string(m_listenPort) + "is occupied)"); diff --git a/src/websocket/service/ws_server.h b/src/websocket/service/ws_server.h index 3b164cd..5a8d269 100644 --- a/src/websocket/service/ws_server.h +++ b/src/websocket/service/ws_server.h @@ -116,7 +116,7 @@ private: RouteCallbackRegister m_handler; static std::map m_wsis; url::URLDatum m_url; - int m_listenPort = 10251; + int m_listenPort; }; ssize_t WsWriteToClient(void *context, const void *data, size_t len);