Commit 6ca42581 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

plugins/slurm: Unify formatting

parent 2c71eece
Loading
Loading
Loading
Loading
+276 −280
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@
#define TAG_MODE       3
#define TAG_CONTEXT_ID 4

// clang-format off
SPANK_PLUGIN (admire-cli, 1)
// clang-format on

static int scord_flag = 0;

@@ -62,47 +64,30 @@ static long adhoc_walltime = 0;
static ADM_adhoc_mode_t adhoc_mode = 0;
static char adhoc_id[ADHOCID_LEN] = {0};

static int process_opts(int val, const char *optarg, int remote);
static int
process_opts(int val, const char* optarg, int remote);

struct spank_option spank_opts[] = {
        {
		"adm-adhoc-nodes",
		"[nnodes]",
                "adm-adhoc-nodes", "[nnodes]",
                "Dedicate [nnodes] to the ad-hoc storage",
                1,                            /* option takes an argument */
                TAG_NNODES,                   /* option tag */
                (spank_opt_cb_f) process_opts /* callback  */
        },
	{
		"adm-adhoc-walltime",
		"[walltime]",
		"Reserve the ad-hoc storage for [walltime] seconds",
		1,
		TAG_WALLTIME,
		(spank_opt_cb_f)process_opts
	},
	{
		"adm-adhoc-context",
		"[context]",
        {"adm-adhoc-walltime", "[walltime]",
         "Reserve the ad-hoc storage for [walltime] seconds", 1, TAG_WALLTIME,
         (spank_opt_cb_f) process_opts},
        {"adm-adhoc-context", "[context]",
         "Mode of operation for the ad-hoc storage: in_job:shared|dedicated | separate:new|existing",
		1,
		TAG_MODE,
		(spank_opt_cb_f)process_opts
	},
	{
		"adm-adhoc-context-id",
		"[context_id]",
		"Context ID of the ad-hoc storage",
		1,
		TAG_CONTEXT_ID,
		(spank_opt_cb_f)process_opts
	},
	SPANK_OPTIONS_TABLE_END
};
         1, TAG_MODE, (spank_opt_cb_f) process_opts},
        {"adm-adhoc-context-id", "[context_id]",
         "Context ID of the ad-hoc storage", 1, TAG_CONTEXT_ID,
         (spank_opt_cb_f) process_opts},
        SPANK_OPTIONS_TABLE_END};

static int
process_opts(int tag, const char *optarg, int remote)
{
process_opts(int tag, const char* optarg, int remote) {
    (void) remote;

    /* srun & sbatch/salloc */
@@ -173,8 +158,8 @@ process_opts(int tag, const char *optarg, int remote)
}

static int
scord_register_job(const char *scord_proto, const char *scord_addr, const char *nodelist, uint32_t jobid)
{
scord_register_job(const char* scord_proto, const char* scord_addr,
                   const char* nodelist, uint32_t jobid) {
    int rc = 0;

    ADM_server_t scord_server;
@@ -229,7 +214,8 @@ scord_register_job(const char *scord_proto, const char *scord_addr, const char *

    /* take the ADHOC_NNODES first nodes for the adhoc */
    ADM_adhoc_resources_t adhoc_resources;
	adhoc_resources = ADM_adhoc_resources_create(nodes, adhoc_nnodes < nnodes ? adhoc_nnodes : nnodes);
    adhoc_resources = ADM_adhoc_resources_create(
            nodes, adhoc_nnodes < nnodes ? adhoc_nnodes : nnodes);
    if(!adhoc_resources) {
        slurm_error("slurmadmcli: adhoc_resources creation failed");
        rc = -1;
@@ -264,7 +250,8 @@ scord_register_job(const char *scord_proto, const char *scord_addr, const char *
    }

    ADM_job_t scord_job;
	if (ADM_register_job(scord_server, job_resources, scord_reqs, jobid, &scord_job) != ADM_SUCCESS) {
    if(ADM_register_job(scord_server, job_resources, scord_reqs, jobid,
                        &scord_job) != ADM_SUCCESS) {
        slurm_error("slurmadmcli: scord job registration failed");
        rc = -1;
        goto end;
@@ -288,8 +275,7 @@ end:
}

int
slurm_spank_init(spank_t sp, int ac, char **av)
{
slurm_spank_init(spank_t sp, int ac, char** av) {
    (void) ac;
    (void) av;

@@ -309,8 +295,7 @@ slurm_spank_init(spank_t sp, int ac, char **av)


int
slurm_spank_local_user_init(spank_t sp, int ac, char **av)
{
slurm_spank_local_user_init(spank_t sp, int ac, char** av) {
    (void) sp;

    if(!scord_flag)
@@ -356,15 +341,26 @@ slurm_spank_local_user_init(spank_t sp, int ac, char **av)
    }


	/* launch one scord-ctl task on one node in the allocation, let Slurm decide which */
    /* launch one scord-ctl task on one node in the allocation, let Slurm decide
     * which */
    pid_t pid;
    if((pid = fork()) < 0) {
		slurm_error("slurmadmcli: failed to start scord-ctl: %s", strerror(errno));
        slurm_error("slurmadmcli: failed to start scord-ctl: %s",
                    strerror(errno));
        return -1;
    } else if(pid == 0) {
		char *argv[] = { "srun", "-N1", "-n1", "--overlap", "--cpu-bind=none", "--jobid", sjobid, (char *const)scordctl_bin, NULL };
        char* argv[] = {"srun",
                        "-N1",
                        "-n1",
                        "--overlap",
                        "--cpu-bind=none",
                        "--jobid",
                        sjobid,
                        (char* const) scordctl_bin,
                        NULL};
        execvp(argv[0], argv);
		slurm_error("slurmadmcli: failed to srun scord-ctl: %s", strerror(errno));
        slurm_error("slurmadmcli: failed to srun scord-ctl: %s",
                    strerror(errno));
        return 0;
    }