Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brought __rpc_num2string in sync with slurm 22.05 message types #261

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 82 additions & 54 deletions pyslurm/pyslurm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,10 @@ cdef class statistics:
rpc_type_stats = {}

for i in range(self._buf.rpc_type_size):
rpc_type = self.__rpc_num2string(self._buf.rpc_type_id[i])
try:
rpc_type = self.__rpc_num2string(self._buf.rpc_type_id[i])
except KeyError:
rpc_type = "UNKNOWN"
rpc_type_stats[rpc_type] = {}
rpc_type_stats[rpc_type]['id'] = self._buf.rpc_type_id[i]
rpc_type_stats[rpc_type]['count'] = self._buf.rpc_type_cnt[i]
Expand Down Expand Up @@ -4725,10 +4728,10 @@ cdef class statistics:
1001: "REQUEST_NODE_REGISTRATION_STATUS",
1002: "MESSAGE_NODE_REGISTRATION_STATUS",
1003: "REQUEST_RECONFIGURE",
1004: "RESPONSE_RECONFIGURE",
1004: "REQUEST_RECONFIGURE_WITH_CONFIG",
1005: "REQUEST_SHUTDOWN",
1006: "REQUEST_SHUTDOWN_IMMEDIATE",
1007: "RESPONSE_SHUTDOWN",
1006: "DEFUNCT_RPC_1006",
1007: "DEFUNCT_RPC_1007",
1008: "REQUEST_PING",
1009: "REQUEST_CONTROL",
1010: "REQUEST_SET_DEBUG_LEVEL",
Expand All @@ -4745,9 +4748,10 @@ cdef class statistics:
1021: "REQUEST_LICENSE_INFO",
1022: "RESPONSE_LICENSE_INFO",
1023: "REQUEST_SET_FS_DAMPENING_FACTOR",
1024: "RESPONSE_NODE_REGISTRATION",

1400: "DBD_MESSAGES_START",
1433: "PERSIST_RC",

2000: "DBD_MESSAGES_END",

2001: "REQUEST_BUILD_INFO",
Expand All @@ -4760,12 +4764,12 @@ cdef class statistics:
2008: "RESPONSE_NODE_INFO",
2009: "REQUEST_PARTITION_INFO",
2010: "RESPONSE_PARTITION_INFO",
2011: "REQUEST_ACCTING_INFO",
2012: "RESPONSE_ACCOUNTING_INFO",
2011: "DEFUNCT_RPC_2011",
2012: "DEFUNCT_RPC_2012",
2013: "REQUEST_JOB_ID",
2014: "RESPONSE_JOB_ID",
2015: "REQUEST_BLOCK_INFO",
2016: "RESPONSE_BLOCK_INFO",
2015: "REQUEST_CONFIG",
2016: "RESPONSE_CONFIG",
2017: "REQUEST_TRIGGER_SET",
2018: "REQUEST_TRIGGER_GET",
2019: "REQUEST_TRIGGER_CLEAR",
Expand All @@ -4782,22 +4786,22 @@ cdef class statistics:
2030: "REQUEST_TRIGGER_PULL",
2031: "REQUEST_FRONT_END_INFO",
2032: "RESPONSE_FRONT_END_INFO",
2033: "REQUEST_SPANK_ENVIRONMENT",
2034: "RESPONCE_SPANK_ENVIRONMENT",
2033: "DEFUNCT_RPC_2033",
2034: "DEFUNCT_RPC_2034",
2035: "REQUEST_STATS_INFO",
2036: "RESPONSE_STATS_INFO",
2037: "REQUEST_BURST_BUFFER_INFO",
2038: "RESPONSE_BURST_BUFFER_INFO",
2039: "REQUEST_JOB_USER_INFO",
2040: "REQUEST_NODE_INFO_SINGLE",
2041: "REQUEST_POWERCAP_INFO",
2042: "RESPONSE_POWERCAP_INFO",
2041: "DEFUNCT_RPC_2041",
2042: "DEFUNCT_RPC_2042",
2043: "REQUEST_ASSOC_MGR_INFO",
2044: "RESPONSE_ASSOC_MGR_INFO",
2045: "REQUEST_SICP_INFO_DEFUNCT",
2046: "RESPONSE_SICP_INFO_DEFUNCT",
2047: "REQUEST_LAYOUT_INFO",
2048: "RESPONSE_LAYOUT_INFO",
2045: "DEFUNCT_RPC_2045",
2046: "DEFUNCT_RPC_2046",
2047: "DEFUNCT_RPC_2047",
2048: "DEFUNCT_RPC_2048",
2049: "REQUEST_FED_INFO",
2050: "RESPONSE_FED_INFO",
2051: "REQUEST_BATCH_SCRIPT",
Expand All @@ -4807,6 +4811,11 @@ cdef class statistics:
2055: "REQUEST_BURST_BUFFER_STATUS",
2056: "RESPONSE_BURST_BUFFER_STATUS",

2200: "REQUEST_CRONTAB",
2201: "RESPONSE_CRONTAB",
2202: "REQUEST_UPDATE_CRONTAB",
2203: "RESPONSE_UPDATE_CRONTAB",

3001: "REQUEST_UPDATE_JOB",
3002: "REQUEST_UPDATE_NODE",
3003: "REQUEST_CREATE_PARTITION",
Expand All @@ -4816,61 +4825,65 @@ cdef class statistics:
3007: "RESPONSE_CREATE_RESERVATION",
3008: "REQUEST_DELETE_RESERVATION",
3009: "REQUEST_UPDATE_RESERVATION",
3010: "REQUEST_UPDATE_BLOCK",
3010: "DEFUNCT_RPC_3010",
3011: "REQUEST_UPDATE_FRONT_END",
3012: "REQUEST_UPDATE_LAYOUT",
3013: "REQUEST_UPDATE_POWERCAP",
3012: "DEFUNCT_RPC_3012",
3013: "DEFUNCT_RPC_3013",
3014: "REQUEST_DELETE_NODE",
3015: "REQUEST_CREATE_NODE",

4001: "REQUEST_RESOURCE_ALLOCATION",
4002: "RESPONSE_RESOURCE_ALLOCATION",
4003: "REQUEST_SUBMIT_BATCH_JOB",
4004: "RESPONSE_SUBMIT_BATCH_JOB",
4005: "REQUEST_BATCH_JOB_LAUNCH",
4006: "REQUEST_CANCEL_JOB",
4007: "RESPONSE_CANCEL_JOB",
4008: "REQUEST_JOB_RESOURCE",
4009: "RESPONSE_JOB_RESOURCE",
4010: "REQUEST_JOB_ATTACH",
4011: "RESPONSE_JOB_ATTACH",
4007: "DEFUNCT_RPC_4007",
4008: "DEFUNCT_RPC_4008",
4009: "DEFUNCT_RPC_4009",
4010: "DEFUNCT_RPC_4010",
4011: "DEFUNCT_RPC_4011",
4012: "REQUEST_JOB_WILL_RUN",
4013: "RESPONSE_JOB_WILL_RUN",
4014: "REQUEST_JOB_ALLOCATION_INFO",
4015: "RESPONSE_JOB_ALLOCATION_INFO",
4016: "DEFUNCT_REQUEST_JOB_ALLOCATION_INFO_LITE",
4017: "DEFUNCT_RESPONSE_JOB_ALLOCATION_INFO_LITE",
4018: "REQUEST_UPDATE_JOB_TIME",
4016: "DEFUNCT_RPC_4017",
4017: "DEFUNCT_RPC_4018",
4018: "DEFUNCT_RPC_4019",
4019: "REQUEST_JOB_READY",
4020: "RESPONSE_JOB_READY",
4021: "REQUEST_JOB_END_TIME",
4022: "REQUEST_JOB_NOTIFY",
4023: "REQUEST_JOB_SBCAST_CRED",
4024: "RESPONSE_JOB_SBCAST_CRED",
4025: "REQUEST_JOB_PACK_ALLOCATION",
4026: "RESPONSE_JOB_PACK_ALLOCATION",
4027: "REQUEST_JOB_PACK_ALLOC_INFO",
4028: "REQUEST_SUBMIT_BATCH_JOB_PACK",
4025: "REQUEST_HET_JOB_ALLOCATION",
4026: "RESPONSE_HET_JOB_ALLOCATION",
4027: "REQUEST_HET_JOB_ALLOC_INFO",
4028: "REQUEST_SUBMIT_BATCH_HET_JOB",

4500: "REQUEST_CTLD_MULT_MSG",
4501: "RESPONSE_CTLD_MULT_MSG",
4502: "REQUEST_SIB_MSG",
4503: "REQUEST_SIB_JOB_LOCK",
4504: "REQUEST_SIB_JOB_UNLOCK",
4505: "REQUEST_SEND_DEP",
4506: "REQUEST_UPDATE_ORIGIN_DEP",

5001: "REQUEST_JOB_STEP_CREATE",
5002: "RESPONSE_JOB_STEP_CREATE",
5003: "REQUEST_RUN_JOB_STEP",
5004: "RESPONSE_RUN_JOB_STEP",
5003: "DEFUNCT_RPC_5003",
5004: "DEFUNCT_RPC_5004",
5005: "REQUEST_CANCEL_JOB_STEP",
5006: "RESPONSE_CANCEL_JOB_STEP",
5006: "DEFUNCT_RPC_5006",
5007: "REQUEST_UPDATE_JOB_STEP",
5008: "DEFUNCT_RESPONSE_COMPLETE_JOB_STEP",
5009: "REQUEST_CHECKPOINT",
5010: "RESPONSE_CHECKPOINT",
5011: "REQUEST_CHECKPOINT_COMP",
5012: "REQUEST_CHECKPOINT_TASK_COMP",
5013: "RESPONSE_CHECKPOINT_COMP",
5008: "DEFUNCT_RPC_5008",
5009: "DEFUNCT_RPC_5009",
5010: "DEFUNCT_RPC_5010",
5011: "DEFUNCT_RPC_5011",
5012: "DEFUNCT_RPC_5012",
5013: "DEFUNCT_RPC_5013",
5014: "REQUEST_SUSPEND",
5015: "RESPONSE_SUSPEND",
5015: "DEFUNCT_RPC_5015",
5016: "REQUEST_STEP_COMPLETE",
5017: "REQUEST_COMPLETE_JOB_ALLOCATION",
5018: "REQUEST_COMPLETE_BATCH_SCRIPT",
Expand All @@ -4881,51 +4894,60 @@ cdef class statistics:
5023: "REQUEST_JOB_REQUEUE",
5024: "REQUEST_DAEMON_STATUS",
5025: "RESPONSE_SLURMD_STATUS",
5026: "RESPONSE_SLURMCTLD_STATUS",
5026: "DEFUNCT_RPC_5026",
5027: "REQUEST_JOB_STEP_PIDS",
5028: "RESPONSE_JOB_STEP_PIDS",
5029: "REQUEST_FORWARD_DATA",
5030: "REQUEST_COMPLETE_BATCH_JOB",
5030: "DEFUNCT_RPC_5030",
5031: "REQUEST_SUSPEND_INT",
5032: "REQUEST_KILL_JOB",
5033: "REQUEST_KILL_JOBSTEP",
5033: "DEFUNCT_RPC_5033",
5034: "RESPONSE_JOB_ARRAY_ERRORS",
5035: "REQUEST_NETWORK_CALLERID",
5036: "RESPONSE_NETWORK_CALLERID",
5037: "REQUEST_STEP_COMPLETE_AGGR",
5037: "DEFUNCT_RPC_5037",
5038: "REQUEST_TOP_JOB",
5039: "REQUEST_AUTH_TOKEN",
5040: "RESPONSE_AUTH_TOKEN",

6001: "REQUEST_LAUNCH_TASKS",
6002: "RESPONSE_LAUNCH_TASKS",
6003: "MESSAGE_TASK_EXIT",
6004: "REQUEST_SIGNAL_TASKS",
6005: "REQUEST_CHECKPOINT_TASKS",
6005: "DEFUNCT_RPC_6005",
6006: "REQUEST_TERMINATE_TASKS",
6007: "REQUEST_REATTACH_TASKS",
6008: "RESPONSE_REATTACH_TASKS",
6009: "REQUEST_KILL_TIMELIMIT",
6010: "DEFUNCT_REQUEST_SIGNAL_JOB",
6010: "DEFUNCT_RPC_6010",
6011: "REQUEST_TERMINATE_JOB",
6012: "MESSAGE_EPILOG_COMPLETE",
6013: "REQUEST_ABORT_JOB",

6014: "REQUEST_FILE_BCAST",
6015: "TASK_USER_MANAGED_IO_STREAM",
6015: "DEFUNCT_RPC_6015",
6016: "REQUEST_KILL_PREEMPTED",

6017: "REQUEST_LAUNCH_PROLOG",
6018: "REQUEST_COMPLETE_PROLOG",
6019: "RESPONSE_PROLOG_EXECUTING",

6500: "REQUEST_PERSIST_INIT",

7001: "SRUN_PING",
7002: "SRUN_TIMEOUT",
7003: "SRUN_NODE_FAIL",
7004: "SRUN_JOB_COMPLETE",
7005: "SRUN_USER_MSG",
7006: "SRUN_EXEC",
7006: "DEFUNCT_RPC_7006",
7007: "SRUN_STEP_MISSING",
7008: "SRUN_REQUEST_SUSPEND",
7009: "SRUN_STEP_SIGNAL",

7010: "SRUN_NET_FORWARD",

7201: "PMI_KVS_PUT_REQ",
7202: "PMI_KVS_PUT_RESP",
7202: "DEFUNCT_RPC_7202",
7203: "PMI_KVS_GET_REQ",
7204: "PMI_KVS_GET_RESP",

Expand All @@ -4941,9 +4963,15 @@ cdef class statistics:
10004: "ACCOUNTING_TRES_CHANGE_DB",
10005: "ACCOUNTING_NODES_CHANGE_DB",

11001: "MESSAGE_COMPOSITE",
11002: "RESPONSE_MESSAGE_COMPOSITE"}

11001: "SLURMSCRIPTD_REQUEST_FLUSH",
11002: "SLURMSCRIPTD_REQUEST_FLUSH_JOB",
11003: "SLURMSCRIPTD_REQUEST_RECONFIG",
11004: "SLURMSCRIPTD_REQUEST_RUN_SCRIPT",
11005: "SLURMSCRIPTD_REQUEST_SCRIPT_COMPLETE",
11006: "SLURMSCRIPTD_REQUEST_UPDATE_DEBUG_FLAGS",
11007: "SLURMSCRIPTD_REQUEST_UPDATE_LOG",
11008: "SLURMSCRIPTD_SHUTDOWN",
}
return num2string[opcode]


Expand Down
46 changes: 46 additions & 0 deletions scripts/slurm_msg_type_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /usr/bin/env python3
"""
Parse $slurmrepo/src/common/slurm_protocol_defs.h and create
a small C program that generates a mapping of the numeric
slurm msg types to their symbolic names.

Example:
./slurm_msg_type_dict.py $slurmrepo/src/common/slurm_protocol_defs.h > msgdict.c
gcc -o msgdict msgdict.c
./msgdict
"""

import re
import sys
import argparse

def generate_c(header_file_name):
typedef_re = re.compile(r"\s*typedef\s+enum\s*{(.*?)}\s*slurm_msg_type_t\s*;", re.DOTALL)
symbol_re = re.compile(r"^\s*([A-Z0-9_]+)\s*[,=\n]")

with open(header_file_name, mode="r", encoding="utf-8") as header_file:
header = header_file.read()
typedef = typedef_re.search(header)
if typedef is None:
print("could not identify the slurm_msg_type_t typedef in the header file")
sys.exit(1)

print("""#include <stdio.h>""")
print(typedef.group(0))
print("""\n\nint main(void) {""")
for line in typedef.group(1).split("\n"):
symbol = symbol_re.match(line)
if symbol is not None:
print(f""" printf("%d: \\\"%s\\\",\\n", {symbol.group(1)}, "{symbol.group(1)}");""")
else:
print(f""" printf("\\n");""")
print(""" return 0;\n}""")

def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("header", help="$slurmrepo/src/common/slurm_protocol_defs.h")
args = parser.parse_args()
generate_c(args.header)

if __name__ == "__main__":
main()