diff --git a/0054-add-restapi-for-scontrol-reconfigure.patch b/0054-add-restapi-for-scontrol-reconfigure.patch new file mode 100644 index 0000000000000000000000000000000000000000..7dfdb0d455a50636b02fae33a6d9b5b91ddeee48 --- /dev/null +++ b/0054-add-restapi-for-scontrol-reconfigure.patch @@ -0,0 +1,166 @@ +From d32bcd338ca9e9f9a76438e7e8c5734fed998dda Mon Sep 17 00:00:00 2001 +From: motodiary +Date: Fri, 21 Jun 2024 10:33:14 +0800 +Subject: [PATCH] add restapi for scontrol reconfigure + +--- + src/plugins/openapi/v0.0.37/Makefile.am | 2 +- + src/plugins/openapi/v0.0.37/api.c | 2 + + src/plugins/openapi/v0.0.37/api.h | 4 ++ + src/plugins/openapi/v0.0.37/openapi.json | 17 ++++++ + src/plugins/openapi/v0.0.37/reconfigure.c | 64 +++++++++++++++++++++++ + 5 files changed, 88 insertions(+), 1 deletion(-) + mode change 100644 => 100755 src/plugins/openapi/v0.0.37/Makefile.am + mode change 100644 => 100755 src/plugins/openapi/v0.0.37/api.c + mode change 100644 => 100755 src/plugins/openapi/v0.0.37/api.h + mode change 100644 => 100755 src/plugins/openapi/v0.0.37/openapi.json + create mode 100755 src/plugins/openapi/v0.0.37/reconfigure.c + +diff --git a/src/plugins/openapi/v0.0.37/Makefile.am b/src/plugins/openapi/v0.0.37/Makefile.am +old mode 100644 +new mode 100755 +index 2fe681a..59c7b4f +--- a/src/plugins/openapi/v0.0.37/Makefile.am ++++ b/src/plugins/openapi/v0.0.37/Makefile.am +@@ -38,7 +38,7 @@ pkglib_LTLIBRARIES = openapi_v0_0_37.la + noinst_LTLIBRARIES = libopenapi_ref.la + + openapi_v0_0_37_la_SOURCES = \ +- api.c api.h diag.c jobs.c nodes.c partitions.c reservations.c ++ api.c api.h diag.c jobs.c nodes.c partitions.c reservations.c reconfigure.c + + openapi_v0_0_37_la_DEPENDENCIES = $(LIB_SLURM_BUILD) + openapi_v0_0_37_la_LDFLAGS = $(PLUGIN_FLAGS) +diff --git a/src/plugins/openapi/v0.0.37/api.c b/src/plugins/openapi/v0.0.37/api.c +old mode 100644 +new mode 100755 +index 9c31084..6fbf219 +--- a/src/plugins/openapi/v0.0.37/api.c ++++ b/src/plugins/openapi/v0.0.37/api.c +@@ -176,6 +176,8 @@ extern void slurm_openapi_p_init(void) + init_op_nodes(); + init_op_partitions(); + init_op_reservations(); ++ ++ init_op_reconfigure(); + } + + extern void slurm_openapi_p_fini(void) +diff --git a/src/plugins/openapi/v0.0.37/api.h b/src/plugins/openapi/v0.0.37/api.h +old mode 100644 +new mode 100755 +index 0265434..7ca7cae +--- a/src/plugins/openapi/v0.0.37/api.h ++++ b/src/plugins/openapi/v0.0.37/api.h +@@ -74,4 +74,8 @@ extern void destroy_op_nodes(void); + extern void destroy_op_partitions(void); + extern void destroy_op_reservations(void); + ++extern void init_op_reconfigure(void); ++extern void destroy_op_reconfigure(void); ++ ++ + #endif +diff --git a/src/plugins/openapi/v0.0.37/openapi.json b/src/plugins/openapi/v0.0.37/openapi.json +old mode 100644 +new mode 100755 +index a374bd7..995235e +--- a/src/plugins/openapi/v0.0.37/openapi.json ++++ b/src/plugins/openapi/v0.0.37/openapi.json +@@ -308,6 +308,23 @@ + } + } + }, ++ "/reconfigure/": { ++ "post": { ++ "tags": [ ++ "slurm" ++ ], ++ "operationId": "scontrol_reconfigure", ++ "summary": "run scontrol reconfigure", ++ "responses": { ++ "200": { ++ "description": "reconfigure succeed", ++ }, ++ "default": { ++ "description": "reconfigure failed" ++ } ++ } ++ } ++ }, + "/nodes/": { + "get": { + "tags": [ +diff --git a/src/plugins/openapi/v0.0.37/reconfigure.c b/src/plugins/openapi/v0.0.37/reconfigure.c +new file mode 100755 +index 0000000..53cf82b +--- /dev/null ++++ b/src/plugins/openapi/v0.0.37/reconfigure.c +@@ -0,0 +1,64 @@ ++/*****************************************************************************\ ++ * reconfigure.c - Slurm REST API reconfigure operations handlers ++ ***************************************************************************** ++ * add by H3C_AMPHA for support scontrol reconfigure ++\*****************************************************************************/ ++ ++#include "config.h" ++ ++ ++#include "slurm/slurm.h" ++#include "src/common/log.h" ++#include "src/slurmrestd/operations.h" ++ ++#include "src/plugins/openapi/v0.0.37/api.h" ++ ++ ++static int _op_handler_reconfigure(const char *context_id, ++ http_request_method_t method, data_t *parameters, ++ data_t *query, int tag, data_t *resp, ++ void *auth) ++{ ++ int rc = SLURM_SUCCESS; ++ data_t *errors = populate_response_format(resp); ++ debug4("%s: reconfigure handler %s called by %s with tag %d", ++ __func__, get_http_method_string(method), context_id, tag); ++ ++ if (method == HTTP_REQUEST_POST){ ++ rc = slurm_reconfigure(); ++ } ++ else{ ++ data_t *errord = data_list_append(errors); ++ data_set_dict(errord); ++ data_set_int(data_key_set(errord, "error_code"), ++ ESLURM_REST_INVALID_QUERY); ++ data_set_string(data_key_set(errord, "error"), ++ "unexpected HTTP method"); ++ ++ error("%s: [%s] reconfigure failed unexpected method:%s tag:%d", ++ __func__, context_id, ++ get_http_method_string(method), tag); ++ rc = ESLURM_REST_INVALID_QUERY; ++ } ++ ++ return rc; ++ ++ ++} ++ ++extern void init_op_reconfigure(void) ++{ ++ bind_operation_handler("/slurm/v0.0.37/reconfigure", _op_handler_reconfigure, ++ 0); ++} ++ ++extern void destroy_op_reconfigure(void) ++{ ++ unbind_operation_handler(_op_handler_reconfigure); ++} ++ ++ ++ ++ ++ ++ +-- +2.33.0 + diff --git a/slurm.spec b/slurm.spec index 15dbf41459a60a0f05e8cda9aedf63c3c447ec6d..b9b3bbff00ed1e4a929bbc8a076c7c718f5dfd2c 100644 --- a/slurm.spec +++ b/slurm.spec @@ -1,6 +1,6 @@ Name: slurm Version: 21.08.8 -%define rel 56 +%define rel 57 Release: %{rel}%{?dist} Summary: Slurm Workload Manager @@ -69,6 +69,7 @@ Patch50: 0050-enable-col_data-empty-check.patch Patch51: 0051-fix-the-archive-error.patch Patch52: 0052-fix-sacctmgr-delete-error-with-flags-specified.patch Patch53: 0053-add-slurmrestd-log.patch +Patch54: 0054-add-restapi-for-scontrol-reconfigure.patch # build options .rpmmacros options change to default action # ==================== ==================== ======================== @@ -761,6 +762,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart slurmdbd.service %changelog +* Fri Jun 21 2024 Xing Liu - 21.08.8-57 +- add restapi for scontrol reconfigure + * Thu Jun 20 2024 Xing Liu - 21.08.8-56 - add slurmrestd.log