Modified makefile rules

This commit is contained in:
Bole Ma 2024-02-14 04:45:40 +08:00
parent a2374e2b6f
commit 5dcd3ca647
4 changed files with 59 additions and 43 deletions

View File

@ -79,6 +79,7 @@ RUN set -x \
/var/run/slurmdbd \ /var/run/slurmdbd \
/var/lib/slurmd \ /var/lib/slurmd \
/var/log/slurm \ /var/log/slurm \
/tmp/pika_debug \
/data \ /data \
&& touch /var/lib/slurmd/node_state \ && touch /var/lib/slurmd/node_state \
/var/lib/slurmd/front_end_state \ /var/lib/slurmd/front_end_state \

View File

@ -14,11 +14,11 @@ services:
- var_lib_mysql:/var/lib/mysql - var_lib_mysql:/var/lib/mysql
slurmdbd: slurmdbd:
image: slurm-docker-cluster:${IMAGE_TAG:-21.08} image: slurm-docker-cluster:${IMAGE_TAG:-22.05}
build: build:
context: . context: .
args: args:
SLURM_TAG: ${SLURM_TAG:-slurm-21-08-6-1} SLURM_TAG: ${SLURM_TAG:-slurm-22-05-2-1}
command: ["slurmdbd"] command: ["slurmdbd"]
container_name: slurmdbd container_name: slurmdbd
hostname: slurmdbd hostname: slurmdbd
@ -32,7 +32,7 @@ services:
- mysql - mysql
slurmctld: slurmctld:
image: slurm-docker-cluster:${IMAGE_TAG:-21.08} image: slurm-docker-cluster:${IMAGE_TAG:-22.05}
command: ["slurmctld"] command: ["slurmctld"]
container_name: slurmctld container_name: slurmctld
hostname: slurmctld hostname: slurmctld
@ -47,7 +47,7 @@ services:
- "slurmdbd" - "slurmdbd"
c1: c1:
image: slurm-docker-cluster:${IMAGE_TAG:-21.08} image: slurm-docker-cluster:${IMAGE_TAG:-22.05}
command: ["slurmd"] command: ["slurmd"]
hostname: c1 hostname: c1
container_name: c1 container_name: c1
@ -62,7 +62,7 @@ services:
- "slurmctld" - "slurmctld"
c2: c2:
image: slurm-docker-cluster:${IMAGE_TAG:-21.08} image: slurm-docker-cluster:${IMAGE_TAG:-22.05}
command: ["slurmd"] command: ["slurmd"]
hostname: c2 hostname: c2
container_name: c2 container_name: c2

View File

@ -1,8 +1,8 @@
SLURM_ROOT_DIR = /usr SLURM_ROOT_DIR = /usr
SLURM_INC_DIR = /usr/include/slurm SLURM_INC_DIR = /usr/include/slurm
SLURM_LIB_DIR = /usr/lib64/slurm SLURM_LIB_DIR = /usr/lib64/slurm
SLURM_BUILD = 21.08.6 SLURM_BUILD = 22.05.2
SLURM_BUILD_DIR = /srv/slurm SLURM_BUILD_DIR = /opt/slurm
PLUGIN_TYPE = prep PLUGIN_TYPE = prep
PLUGIN_NAME = pika PLUGIN_NAME = pika
@ -11,7 +11,7 @@ PLUGIN_FILE = $(PLUGIN_TYPE)_$(PLUGIN_NAME).so
SRC_FILE = slurm-prep-pika_v4.c SRC_FILE = slurm-prep-pika_v4.c
CC = gcc CC = gcc
CFLAGS ?= -Wall -fPIC -g -I$(SLURM_INC_DIR) -I$(SLURM_BUILD_DIR) -I/srv/slurm/src/ -I/srv/slurm CFLAGS ?= -Wall -fPIC -g -I$(SLURM_INC_DIR) -I$(SLURM_BUILD_DIR) -I/opt/slurm/src/ -I/opt/nats.c/src
LDFLAGS ?= --shared -L. LDFLAGS ?= --shared -L.
all: $(PLUGIN_FILE) all: $(PLUGIN_FILE)

View File

@ -4,7 +4,7 @@
***************************************************************************** *****************************************************************************
* Written by Mike Arnhold and Frank Winkler * Written by Mike Arnhold and Frank Winkler
* *
* https://gitlab.hrz.tu-chemnitz.de/pika/pika-packages/-/raw/master/pika-prep-plugin/slurm-prep-pika_v4.c * LICENSE NOTICE ?!?!?!?!
\*****************************************************************************/ \*****************************************************************************/
#include <stdarg.h> #include <stdarg.h>
@ -22,10 +22,6 @@
#include "src/common/parse_time.h" #include "src/common/parse_time.h"
#include "src/common/uid.h" #include "src/common/uid.h"
#include "src/interfaces/data_parser.h"
#include "src/common/data.h"
#include "src/common/openapi.h"
#include "src/slurmrestd/plugins/openapi/slurmctld/api.h"
#define P_NAME "PrEp-pika: " #define P_NAME "PrEp-pika: "
#define BUFF_LEN 128 #define BUFF_LEN 128
@ -322,27 +318,31 @@ extern void prep_p_register_callbacks(prep_callbacks_t *callbacks)
extern int prep_p_prolog(job_env_t *job_env, slurm_cred_t *cred) extern int prep_p_prolog(job_env_t *job_env, slurm_cred_t *cred)
{ {
printf("Started job id: %d\n", job_env->jobid); printf("Started job id: %d\n", job_env->jobid);
char *json;
job_record_t *job_ptr = find_job_record(job_env->jobid);
int rc;
internal_error_t _rc = job_ptr_to_json(job_ptr, &json, false);
if (_rc) {
slurm_error(P_NAME "%s", error_to_string(_rc));
rc = SLURM_ERROR;
}
job_info_msg_t *job_info_ptr = NULL; // Some async task
int rc; if (rc == SLURM_SUCCESS) {
pika_metadata_log(job_ptr->job_id, json, false);
printf("%s: jobs handler called", __func__); natsConnection *nc = NULL;
natsSubscription *sub = NULL;
rc = slurm_load_job(&job_info_ptr, job_env->jobid, SHOW_ALL | SHOW_DETAIL); // Connects to the default NATS Server running locally
natsConnection_ConnectTo(&nc, NATS_DEFAULT_URL);
if (rc == SLURM_ERROR || rc == SLURM_UNEXPECTED_MSG_ERROR) { // Simple publisher to send the given json string to subject "slurm_start_job"
printf("Unable to query job: %d\n", job_env->jobid); natsConnection_PublishString(nc, "slurm_start_job", json);
slurm_free_job_info_msg(job_info_ptr);
return SLURM_ERROR; natsSubscription_Destroy(sub);
} natsConnection_Close(nc);
}
ctxt_t *ctxt = NULL;
// init_connection(context_id, method, parameters, query, tag, resp, auth);
DATA_DUMP(ctxt->parser, JOB_INFO_MSG, *job_info_ptr,
data_key_set(resp, "jobs"));
slurm_free_job_info_msg(job_info_ptr);
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
@ -350,6 +350,32 @@ extern int prep_p_prolog(job_env_t *job_env, slurm_cred_t *cred)
extern int prep_p_epilog(job_env_t *job_env, slurm_cred_t *cred) extern int prep_p_epilog(job_env_t *job_env, slurm_cred_t *cred)
{ {
printf("Ended job id: %d, exit code: %d\n", job_env->jobid, job_env->exit_code); printf("Ended job id: %d, exit code: %d\n", job_env->jobid, job_env->exit_code);
char *json;
job_record_t *job_ptr = find_job_record(job_env->jobid);
int rc;
internal_error_t _rc = job_ptr_to_json(job_ptr, &json, false);
if (_rc) {
slurm_error(P_NAME "%s", error_to_string(_rc));
rc = SLURM_ERROR;
}
// Some async task
if (rc == SLURM_SUCCESS) {
pika_metadata_log(job_ptr->job_id, json, false);
natsConnection *nc = NULL;
natsSubscription *sub = NULL;
// Connects to the default NATS Server running locally
natsConnection_ConnectTo(&nc, NATS_DEFAULT_URL);
// Simple publisher to send the given json string to subject "slurm_start_job"
natsConnection_PublishString(nc, "slurm_start_job", json);
natsSubscription_Destroy(sub);
natsConnection_Close(nc);
}
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
@ -382,18 +408,6 @@ extern int prep_p_prolog_slurmctld(job_record_t *job_ptr, bool *async)
// Some async task // Some async task
if (rc == SLURM_SUCCESS) { if (rc == SLURM_SUCCESS) {
pika_metadata_log(job_ptr->job_id, json, false); pika_metadata_log(job_ptr->job_id, json, false);
natsConnection *nc = NULL;
natsSubscription *sub = NULL;
// Connects to the default NATS Server running locally
natsConnection_ConnectTo(&nc, NATS_DEFAULT_URL);
// Simple publisher to send the given json string to subject "slurm_start_job"
natsConnection_PublishString(nc, "slurm_start_job", json);
natsSubscription_Destroy(sub);
natsConnection_Close(nc);
} }
return rc; return rc;
@ -990,7 +1004,7 @@ static int pika_metadata_log(int job_id, char *json, bool is_epilog)
internal_error_t rc = SUCCESS; internal_error_t rc = SUCCESS;
char file_path[100]; char file_path[100];
sprintf(file_path, "/tmp/pika_debug/pika_prep_%d.log", job_id); sprintf(file_path, "/tmp/pika_debug/pika_prep_%d.log", job_id);
//sprintf(file_path, "/var/log/slurm/pika.log"); // sprintf(file_path, "/var/log/slurm/pika.log");
slurm_mutex_lock(&plugin_log_lock); slurm_mutex_lock(&plugin_log_lock);
@ -1013,4 +1027,5 @@ static int pika_metadata_log(int job_id, char *json, bool is_epilog)
slurm_mutex_unlock(&plugin_log_lock); slurm_mutex_unlock(&plugin_log_lock);
return rc >= 0 ? SUCCESS : rc; return rc >= 0 ? SUCCESS : rc;
} }