Beispiel #1
0
/*
 * Note that a step has terminated.
 *
 * RET - slurm error code
 */
extern int post_step(slurmd_job_t *job)
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.post_step))(job);
}
Beispiel #2
0
/*
 * Note that a task launch is about to occur.
 *
 * RET - slurm error code
 */
extern int pre_launch(slurmd_job_t *job)
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.pre_launch))(job);
}
Beispiel #3
0
/*
 * Slurmd is releasing resources for the task.
 *
 * RET - slurm error code
 */
extern int slurmd_release_resources(uint32_t job_id)
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.slurmd_release_resources))(job_id);
}
Beispiel #4
0
/*
 * Slurmd is resuming a previously suspended job.
 *
 * RET - slurm error code
 */
extern int slurmd_resume_job(uint32_t job_id)
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.slurmd_resume_job))(job_id);
}
Beispiel #5
0
/*
 * Slurmd has received a batch job launch request.
 *
 * RET - slurm error code
 */
extern int slurmd_batch_request(uint32_t job_id, batch_job_launch_msg_t *req)
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.slurmd_batch_request))(job_id, req);
}
Beispiel #6
0
/*
 * Slurmd is reserving resources for the task.
 *
 * RET - slurm error code
 */
extern int slurmd_reserve_resources(uint32_t job_id,
				    launch_tasks_request_msg_t *req,
				    uint32_t node_id )
{
	if (slurmd_task_init())
		return SLURM_ERROR;

	return (*(g_task_context->ops.slurmd_reserve_resources))(job_id, req, node_id);
}
Beispiel #7
0
/*
 * Note that a step has terminated.
 *
 * RET - slurm error code
 */
extern int post_step(slurmd_job_t *job)
{
	int i, rc = SLURM_SUCCESS;

	if (slurmd_task_init())
		return SLURM_ERROR;

	slurm_mutex_lock( &g_task_context_lock );
	for (i = 0; ((i < g_task_context_num) && (rc == SLURM_SUCCESS)); i++)
		rc = (*(g_task_context[i]->ops.post_step))(job);
	slurm_mutex_unlock( &g_task_context_lock );

	return (rc);
}
Beispiel #8
0
/*
 * Slurmd is resuming a previously suspended job.
 *
 * RET - slurm error code
 */
extern int slurmd_resume_job(uint32_t job_id)
{
	int i, rc = SLURM_SUCCESS;

	if (slurmd_task_init())
		return SLURM_ERROR;

	slurm_mutex_lock( &g_task_context_lock );
	for (i = 0; ((i < g_task_context_num) && (rc == SLURM_SUCCESS)); i++)
		rc = (*(g_task_context[i]->ops.slurmd_resume_job))(job_id);
	slurm_mutex_unlock( &g_task_context_lock );

	return (rc);
}
Beispiel #9
0
/*
 * Slurmd has received a batch job launch request.
 *
 * RET - slurm error code
 */
extern int slurmd_batch_request(uint32_t job_id, batch_job_launch_msg_t *req)
{
	int i, rc = SLURM_SUCCESS;

	if (slurmd_task_init())
		return SLURM_ERROR;

	slurm_mutex_lock( &g_task_context_lock );
	for (i = 0; ((i < g_task_context_num) && (rc == SLURM_SUCCESS)); i++) {
		rc = (*(g_task_context[i]->ops.slurmd_batch_request))(job_id,
								      req);
	}
	slurm_mutex_unlock( &g_task_context_lock );

	return (rc);
}
Beispiel #10
0
/*
 * Slurmd is reserving resources for the task.
 *
 * RET - slurm error code
 */
extern int slurmd_reserve_resources(uint32_t job_id,
				    launch_tasks_request_msg_t *req,
				    uint32_t node_id )
{
	int i, rc = SLURM_SUCCESS;

	if (slurmd_task_init())
		return SLURM_ERROR;

	slurm_mutex_lock( &g_task_context_lock );
	for (i = 0; ((i < g_task_context_num) && (rc == SLURM_SUCCESS)); i++) {
		rc = (*(g_task_context[i]->ops.slurmd_reserve_resources))
					(job_id, req, node_id);
	}
	slurm_mutex_unlock( &g_task_context_lock );

	return (rc);
}
Beispiel #11
0
static int
_slurmd_init(void)
{
	struct rlimit rlim;
	slurm_ctl_conf_t *cf;
	struct stat stat_buf;
	uint32_t cpu_cnt;

	/*
	 * Process commandline arguments first, since one option may be
	 * an alternate location for the slurm config file.
	 */
	_process_cmdline(*conf->argc, *conf->argv);

	/*
	 * Build nodes table like in slurmctld
	 * This is required by the topology stack
	 * Node tables setup must preceed _read_config() so that the
	 * proper hostname is set.
	 */
	slurm_conf_init(conf->conffile);
	init_node_conf();
	/* slurm_select_init() must be called before
	 * build_all_nodeline_info() to be called with proper argument. */
	if (slurm_select_init(1) != SLURM_SUCCESS )
		return SLURM_FAILURE;
	build_all_nodeline_info(true);
	build_all_frontend_info(true);

	/*
	 * Read global slurm config file, override necessary values from
	 * defaults and command line.
	 */
	_read_config();

	cpu_cnt = MAX(conf->conf_cpus, conf->block_map_size);

	if ((gres_plugin_init() != SLURM_SUCCESS) ||
	    (gres_plugin_node_config_load(cpu_cnt) != SLURM_SUCCESS))
		return SLURM_FAILURE;
	if (slurm_topo_init() != SLURM_SUCCESS)
		return SLURM_FAILURE;

	/*
	 * Get and set slurmd topology information
	 * Build node hash table first to speed up the topo build
	 */
	rehash_node();
	slurm_topo_build_config();
	_set_topo_info();

	/*
	 * Check for cpu frequency set capabilities on this node
	 */
	cpu_freq_init(conf);

	_print_conf();

	if (slurm_proctrack_init() != SLURM_SUCCESS)
		return SLURM_FAILURE;
	if (slurmd_task_init() != SLURM_SUCCESS)
		return SLURM_FAILURE;
	if (slurm_auth_init(NULL) != SLURM_SUCCESS)
		return SLURM_FAILURE;
	if (spank_slurmd_init() < 0)
		return SLURM_FAILURE;

	if (getrlimit(RLIMIT_CPU, &rlim) == 0) {
		rlim.rlim_cur = rlim.rlim_max;
		setrlimit(RLIMIT_CPU, &rlim);
		if (rlim.rlim_max != RLIM_INFINITY) {
			error("Slurmd process CPU time limit is %d seconds",
			      (int) rlim.rlim_max);
		}
	}

	if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
		rlim.rlim_cur = rlim.rlim_max;
		setrlimit(RLIMIT_NOFILE, &rlim);
	}
#ifndef NDEBUG
	if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
		rlim.rlim_cur = rlim.rlim_max;
		setrlimit(RLIMIT_CORE, &rlim);
	}
#endif /* !NDEBUG */

	/*
	 * Create a context for verifying slurm job credentials
	 */
	if (!(conf->vctx = slurm_cred_verifier_ctx_create(conf->pubkey)))
		return SLURM_FAILURE;
	if (!strcmp(conf->select_type, "select/serial")) {
		/* Only cache credential for 5 seconds with select/serial
		 * for shorter cache searches and higher throughput */
		slurm_cred_ctx_set(conf->vctx, SLURM_CRED_OPT_EXPIRY_WINDOW, 5);
	}

	/*
	 * Create slurmd spool directory if necessary.
	 */
	if (_set_slurmd_spooldir() < 0) {
		error("Unable to initialize slurmd spooldir");
		return SLURM_FAILURE;
	}

	if (conf->cleanstart) {
		/*
		 * Need to kill any running slurmd's here
		 */
		_kill_old_slurmd();

		stepd_cleanup_sockets(conf->spooldir, conf->node_name);
		_stepd_cleanup_batch_dirs(conf->spooldir, conf->node_name);
	}

	if (conf->daemonize) {
		bool success = false;

		if (conf->logfile && (conf->logfile[0] == '/')) {
			char *slash_ptr, *work_dir;
			work_dir = xstrdup(conf->logfile);
			slash_ptr = strrchr(work_dir, '/');
			if (slash_ptr == work_dir)
				work_dir[1] = '\0';
			else
				slash_ptr[0] = '\0';
			if ((access(work_dir, W_OK) != 0) ||
			    (chdir(work_dir) < 0)) {
				error("Unable to chdir to %s", work_dir);
			} else
				success = true;
			xfree(work_dir);
		}

		if (!success) {
			if ((access(conf->spooldir, W_OK) != 0) ||
			    (chdir(conf->spooldir) < 0)) {
				error("Unable to chdir to %s", conf->spooldir);
			} else
				success = true;
		}

		if (!success) {
			if ((access("/var/tmp", W_OK) != 0) ||
			    (chdir("/var/tmp") < 0)) {
				error("chdir(/var/tmp): %m");
				return SLURM_FAILURE;
			} else
				info("chdir to /var/tmp");
		}
	}

	/*
	 * Cache the group access list
	 */
	cf = slurm_conf_lock();
	if (cf->group_info & GROUP_CACHE)
		init_gids_cache(1);
	else
		init_gids_cache(0);
	slurm_conf_unlock();

	if ((devnull = open_cloexec("/dev/null", O_RDWR)) < 0) {
		error("Unable to open /dev/null: %m");
		return SLURM_FAILURE;
	}

	/* make sure we have slurmstepd installed */
	if (stat(conf->stepd_loc, &stat_buf))
		fatal("Unable to find slurmstepd file at %s", conf->stepd_loc);
	if (!S_ISREG(stat_buf.st_mode))
		fatal("slurmstepd not a file at %s", conf->stepd_loc);

	return SLURM_SUCCESS;
}