Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*****************************************************************************\
* proc_msg.c - process incomming messages to slurmctld
*****************************************************************************
* Copyright (C) 2002 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Moe Jette <jette@llnl.gov>, Kevin Tew <tew1@llnl.gov>, et. al.
* UCRL-CODE-2002-040.
*
* This file is part of SLURM, a resource management program.
* For details, see <http://www.llnl.gov/linux/slurm/>.
*
* SLURM is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef WITH_PTHREADS
# include <pthread.h>
#endif /* WITH_PTHREADS */
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <slurm/slurm_errno.h>
#include "src/common/daemonize.h"
#include "src/common/fd.h"
#include "src/common/hostlist.h"
#include "src/common/log.h"
#include "src/common/macros.h"
#include "src/common/pack.h"
#include "src/common/read_config.h"
#include "src/common/slurm_auth.h"
#include "src/common/slurm_cred.h"
#include "src/common/slurm_protocol_api.h"
#include "src/common/xstring.h"
#if HAVE_LIBELAN3
# include "src/common/qsw.h"
#endif
#include "src/slurmctld/agent.h"
#include "src/slurmctld/locks.h"
#include "src/slurmctld/slurmctld.h"
#define BUF_SIZE 1024 /* Temporary buffer size */
#define PRINT_TIMES 0 /* Set to print RPC timers */
#if PRINT_TIMES
# define DEF_TIMERS struct timeval tv1, tv2; char tv_str[20]
# define START_TIMER gettimeofday(&tv1, NULL)
# define END_TIMER gettimeofday(&tv2, NULL); \
_diff_tv_str(&tv1, &tv2, tv_str, 20)
# define TIME_STR tv_str
#else
# define DEF_TIMERS int tv1, tv2, tv_str
# define START_TIMER tv1 = 0
# define END_TIMER tv2 = tv_str = 0
# define TIME_STR ""
#endif
static void _fill_ctld_conf(slurm_ctl_conf_t * build_ptr);
static inline bool _is_super_user(uid_t uid);
static int _make_step_cred(struct step_record *step_rec,
slurm_cred_t *slurm_cred);
inline static void _slurm_rpc_allocate_resources(slurm_msg_t * msg);
inline static void _slurm_rpc_allocate_and_run(slurm_msg_t * msg);
inline static void _slurm_rpc_dump_conf(slurm_msg_t * msg);
inline static void _slurm_rpc_dump_jobs(slurm_msg_t * msg);
inline static void _slurm_rpc_dump_nodes(slurm_msg_t * msg);
inline static void _slurm_rpc_dump_partitions(slurm_msg_t * msg);
inline static void _slurm_rpc_job_step_kill(slurm_msg_t * msg);
inline static void _slurm_rpc_job_step_complete(slurm_msg_t * msg);
inline static void _slurm_rpc_job_step_create(slurm_msg_t * msg);
inline static void _slurm_rpc_job_step_get_info(slurm_msg_t * msg);
inline static void _slurm_rpc_job_will_run(slurm_msg_t * msg);
inline static void _slurm_rpc_node_registration(slurm_msg_t * msg);
inline static void _slurm_rpc_old_job_alloc(slurm_msg_t * msg);
inline static void _slurm_rpc_ping(slurm_msg_t * msg);
inline static void _slurm_rpc_reconfigure_controller(slurm_msg_t * msg);
inline static void _slurm_rpc_shutdown_controller(slurm_msg_t * msg);
inline static void _slurm_rpc_shutdown_controller_immediate(slurm_msg_t *
msg);
inline static void _slurm_rpc_submit_batch_job(slurm_msg_t * msg);
inline static void _slurm_rpc_update_job(slurm_msg_t * msg);
inline static void _slurm_rpc_update_node(slurm_msg_t * msg);
inline static void _slurm_rpc_update_partition(slurm_msg_t * msg);
inline static void _update_cred_key(void);
#if PRINT_TIMES
static void _diff_tv_str(struct timeval *tv1,struct timeval *tv2,
char *tv_str, int len_tv_str)
{
long delta_t;
delta_t = (tv2->tv_sec - tv1->tv_sec) * 1000000;
delta_t += tv2->tv_usec - tv1->tv_usec;
snprintf(tv_str, len_tv_str, "usec=%ld", delta_t);
}
#endif
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
* slurmctld_req - Process an individual RPC request
* IN/OUT - the request message, data associated with the message is freed
*/
void slurmctld_req (slurm_msg_t * msg)
{
switch (msg->msg_type) {
case REQUEST_RESOURCE_ALLOCATION:
_slurm_rpc_allocate_resources(msg);
slurm_free_job_desc_msg(msg->data);
break;
case REQUEST_ALLOCATION_AND_RUN_JOB_STEP:
_slurm_rpc_allocate_and_run(msg);
slurm_free_job_desc_msg(msg->data);
break;
case REQUEST_BUILD_INFO:
_slurm_rpc_dump_conf(msg);
slurm_free_last_update_msg(msg->data);
break;
case REQUEST_JOB_INFO:
_slurm_rpc_dump_jobs(msg);
slurm_free_job_info_request_msg(msg->data);
break;
case REQUEST_NODE_INFO:
_slurm_rpc_dump_nodes(msg);
slurm_free_last_update_msg(msg->data);
break;
case REQUEST_PARTITION_INFO:
_slurm_rpc_dump_partitions(msg);
slurm_free_last_update_msg(msg->data);
break;
case REQUEST_CANCEL_JOB_STEP:
_slurm_rpc_job_step_kill(msg);
slurm_free_job_step_kill_msg(msg->data);
break;
case REQUEST_COMPLETE_JOB_STEP:
_slurm_rpc_job_step_complete(msg);
slurm_free_job_complete_msg(msg->data);
break;
case REQUEST_JOB_STEP_CREATE:
_slurm_rpc_job_step_create(msg);
slurm_free_job_step_create_request_msg(msg->data);
break;
case REQUEST_JOB_STEP_INFO:
_slurm_rpc_job_step_get_info(msg);
slurm_free_job_step_info_request_msg(msg->data);
break;
case REQUEST_JOB_WILL_RUN:
_slurm_rpc_job_will_run(msg->data);
slurm_free_job_desc_msg(msg->data);
break;
case MESSAGE_NODE_REGISTRATION_STATUS:
_slurm_rpc_node_registration(msg);
slurm_free_node_registration_status_msg(msg->data);
break;
case REQUEST_OLD_JOB_RESOURCE_ALLOCATION:
_slurm_rpc_old_job_alloc(msg);
slurm_free_old_job_alloc_msg(msg->data);
break;
case REQUEST_PING:
_slurm_rpc_ping(msg);
/* No body to free */
break;
case REQUEST_RECONFIGURE:
_slurm_rpc_reconfigure_controller(msg);
/* No body to free */
break;
case REQUEST_CONTROL:
_slurm_rpc_shutdown_controller(msg);
/* No body to free */
break;
case REQUEST_SHUTDOWN:
_slurm_rpc_shutdown_controller(msg);
slurm_free_shutdown_msg(msg->data);
break;
case REQUEST_SHUTDOWN_IMMEDIATE:
_slurm_rpc_shutdown_controller_immediate(msg);
/* No body to free */
break;
case REQUEST_SUBMIT_BATCH_JOB:
_slurm_rpc_submit_batch_job(msg);
slurm_free_job_desc_msg(msg->data);
break;
case REQUEST_UPDATE_JOB:
_slurm_rpc_update_job(msg);
slurm_free_job_desc_msg(msg->data);
break;
case REQUEST_UPDATE_NODE:
_slurm_rpc_update_node(msg);
slurm_free_update_node_msg(msg->data);
break;
case REQUEST_UPDATE_PARTITION:
_slurm_rpc_update_partition(msg);
slurm_free_update_part_msg(msg->data);
break;
default:
error("invalid RPC msg_type=%d", msg->msg_type);
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
slurm_send_rc_msg(msg, EINVAL);
break;
}
}
/*
* _fill_ctld_conf - make a copy of current slurm configuration
* this is done with locks set so the data can change at other times
* OUT conf_ptr - place to copy configuration to
*/
void _fill_ctld_conf(slurm_ctl_conf_t * conf_ptr)
{
conf_ptr->last_update = time(NULL);
conf_ptr->authtype = slurmctld_conf.authtype;
conf_ptr->backup_addr = slurmctld_conf.backup_addr;
conf_ptr->backup_controller = slurmctld_conf.backup_controller;
conf_ptr->control_addr = slurmctld_conf.control_addr;
conf_ptr->control_machine = slurmctld_conf.control_machine;
conf_ptr->epilog = slurmctld_conf.epilog;
conf_ptr->fast_schedule = slurmctld_conf.fast_schedule;
conf_ptr->first_job_id = slurmctld_conf.first_job_id;
conf_ptr->hash_base = slurmctld_conf.hash_base;
conf_ptr->heartbeat_interval = slurmctld_conf.heartbeat_interval;
conf_ptr->inactive_limit = slurmctld_conf.inactive_limit;
conf_ptr->job_credential_private_key =
slurmctld_conf.job_credential_private_key;
conf_ptr->job_credential_public_certificate =
slurmctld_conf.job_credential_public_certificate;
conf_ptr->kill_wait = slurmctld_conf.kill_wait;
conf_ptr->max_job_cnt = slurmctld_conf.max_job_cnt;
conf_ptr->min_job_age = slurmctld_conf.min_job_age;
conf_ptr->plugindir = slurmctld_conf.plugindir;
conf_ptr->prioritize = slurmctld_conf.prioritize;
conf_ptr->prolog = slurmctld_conf.prolog;
conf_ptr->ret2service = slurmctld_conf.ret2service;
conf_ptr->slurm_user_id = slurmctld_conf.slurm_user_id;
conf_ptr->slurm_user_name = slurmctld_conf.slurm_user_name;
conf_ptr->slurmctld_debug = slurmctld_conf.slurmctld_debug;
conf_ptr->slurmctld_logfile = slurmctld_conf.slurmctld_logfile;
conf_ptr->slurmctld_pidfile = slurmctld_conf.slurmctld_pidfile;
conf_ptr->slurmctld_port = slurmctld_conf.slurmctld_port;
conf_ptr->slurmctld_timeout = slurmctld_conf.slurmctld_timeout;
conf_ptr->slurmd_debug = slurmctld_conf.slurmd_debug;
conf_ptr->slurmd_logfile = slurmctld_conf.slurmd_logfile;
conf_ptr->slurmd_pidfile = slurmctld_conf.slurmd_pidfile;
conf_ptr->slurmd_port = slurmctld_conf.slurmd_port;
conf_ptr->slurmd_spooldir = slurmctld_conf.slurmd_spooldir;
conf_ptr->slurmd_timeout = slurmctld_conf.slurmd_timeout;
conf_ptr->slurm_conf = slurmctld_conf.slurm_conf;
conf_ptr->state_save_location = slurmctld_conf.state_save_location;
conf_ptr->tmp_fs = slurmctld_conf.tmp_fs;
conf_ptr->wait_time = slurmctld_conf.wait_time;
return;
}
/* return true if supplied uid is a super-user: root, self, or SlurmUser */
static inline bool _is_super_user(uid_t uid)
{
if ( (uid == 0) ||
(uid == slurmctld_conf.slurm_user_id) ||
(uid == getuid()) )
return true;
else
return false;
}
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/* create a credential for a given job step, return error code */
static int _make_step_cred(struct step_record *step_rec,
slurm_cred_t *slurm_cred)
{
slurm_cred_arg_t cred_arg;
cred_arg.jobid = step_rec->job_ptr->job_id;
cred_arg.stepid = step_rec->step_id;
Loading
Loading full blame...