View | Details | Raw Unified | Return to ticket 9056 | Differences between
and this patch

Collapse All | Expand All

(-)a/doc/man/man1/scontrol.1 (-2 / +3 lines)
Lines 333-344 Display the state of the specified entity with the specified identification. Link Here
333
\fIpartition\fP, \fIpowercap\fP, \fIreservation\fP, \fIslurmd\fP, \fIstep\fP,
333
\fIpartition\fP, \fIpowercap\fP, \fIreservation\fP, \fIslurmd\fP, \fIstep\fP,
334
\fItopology\fP, \fIhostlist\fP, \fIhostlistsorted\fP or \fIhostnames\fP
334
\fItopology\fP, \fIhostlist\fP, \fIhostlistsorted\fP or \fIhostnames\fP
335
\fIID\fP can be used to identify a specific element of the identified
335
\fIID\fP can be used to identify a specific element of the identified
336
entity: job ID, node name, partition name, reservation name, or job step ID for
336
entity: node name, partition name, reservation name, or job step ID for
337
\fIjob\fP, \fInode\fP, \fIpartition\fP, or \fIstep\fP respectively.
337
\fInode\fP, \fIpartition\fP, or \fIstep\fP respectively.
338
For an \fIENTITY\fP of \fIbbstat\fP or \fIdwstat\fP (they are equivalent)
338
For an \fIENTITY\fP of \fIbbstat\fP or \fIdwstat\fP (they are equivalent)
339
optional arguments are the options of the local status command.
339
optional arguments are the options of the local status command.
340
The status commands will be executed by the slurmctld daemon and its response
340
The status commands will be executed by the slurmctld daemon and its response
341
returned to the user.
341
returned to the user.
342
For an \fIENTITY\fP of \fIjob\fP a coma separated list of job ID is accepted.
342
For an \fIENTITY\fP of \fItopology\fP, the \fIID\fP may be a node or switch name.
343
For an \fIENTITY\fP of \fItopology\fP, the \fIID\fP may be a node or switch name.
343
If one node name is specified, all switches connected to that node (and
344
If one node name is specified, all switches connected to that node (and
344
their parent switches) will be shown.
345
their parent switches) will be shown.
(-)a/src/scontrol/info_job.c (-41 / +81 lines)
Lines 276-281 scontrol_get_job_state(uint32_t job_id) Link Here
276
	return NO_VAL16;
276
	return NO_VAL16;
277
}
277
}
278
278
279
static bool _job_id_match(job_info_t *job_ptr, uint32_t job_id)
280
{
281
	if (!job_id || job_ptr->job_id == job_id)
282
		return true;
283
	return false;
284
}
285
279
static bool _het_job_offset_match(job_info_t *job_ptr, uint32_t het_job_offset)
286
static bool _het_job_offset_match(job_info_t *job_ptr, uint32_t het_job_offset)
280
{
287
{
281
	if ((het_job_offset == NO_VAL) ||
288
	if ((het_job_offset == NO_VAL) ||
Lines 310-316 static bool _task_id_in_job(job_info_t *job_ptr, uint32_t array_id) Link Here
310
 */
317
 */
311
extern void scontrol_print_job(char * job_id_str)
318
extern void scontrol_print_job(char * job_id_str)
312
{
319
{
313
	int error_code = SLURM_SUCCESS, i, print_cnt = 0;
320
	int error_code = SLURM_SUCCESS, i, print_cnt = 0, exp_cnt = 0;
314
	uint32_t job_id = 0;
321
	uint32_t job_id = 0;
315
	uint32_t array_id = NO_VAL, het_job_offset = NO_VAL;
322
	uint32_t array_id = NO_VAL, het_job_offset = NO_VAL;
316
	job_info_msg_t * job_buffer_ptr = NULL;
323
	job_info_msg_t * job_buffer_ptr = NULL;
Lines 324-343 extern void scontrol_print_job(char * job_id_str) Link Here
324
		 */
331
		 */
325
		while (*tmp_job_ptr) {
332
		while (*tmp_job_ptr) {
326
			if (!isdigit(*tmp_job_ptr) &&
333
			if (!isdigit(*tmp_job_ptr) &&
327
			    (*tmp_job_ptr != '_') && (*tmp_job_ptr != '+')) {
334
			    (*tmp_job_ptr != '_') && (*tmp_job_ptr != '+' &&
335
				(*tmp_job_ptr != ','))) {
328
				exit_code = 1;
336
				exit_code = 1;
329
				slurm_seterrno(ESLURM_INVALID_JOB_ID);
337
				slurm_seterrno(ESLURM_INVALID_JOB_ID);
330
				if (quiet_flag != 1)
338
				if (quiet_flag != 1)
331
					slurm_perror("scontrol_print_job error");
339
					slurm_perror("scontrol_print_job error");
332
				return;
340
				return;
333
			}
341
			}
342
			if (*tmp_job_ptr == ',') {
343
				++exp_cnt;
344
			}
334
			++tmp_job_ptr;
345
			++tmp_job_ptr;
335
		}
346
		}
336
		job_id = (uint32_t) strtol (job_id_str, &end_ptr, 10);
347
		if (!exp_cnt) {
337
		if (end_ptr[0] == '_')
348
			job_id = (uint32_t) strtol (job_id_str, &end_ptr, 10);
338
			array_id = strtol(end_ptr + 1, &end_ptr, 10);
349
			if (end_ptr[0] == '_')
339
		if (end_ptr[0] == '+')
350
				array_id = strtol(end_ptr + 1, &end_ptr, 10);
340
			het_job_offset = strtol(end_ptr + 1, &end_ptr, 10);
351
			if (end_ptr[0] == '+')
352
				het_job_offset = strtol(end_ptr + 1, &end_ptr, 10);
353
			end_ptr = NULL;
354
		}
341
	}
355
	}
342
356
343
	error_code = scontrol_load_job(&job_buffer_ptr, job_id);
357
	error_code = scontrol_load_job(&job_buffer_ptr, job_id);
Lines 355-398 extern void scontrol_print_job(char * job_id_str) Link Here
355
			time_str, job_buffer_ptr->record_count);
369
			time_str, job_buffer_ptr->record_count);
356
	}
370
	}
357
371
358
	for (i = 0, job_ptr = job_buffer_ptr->job_array;
372
	do {
359
	     i < job_buffer_ptr->record_count; i++, job_ptr++) {
373
		if (exp_cnt) {
360
		char *save_array_str = NULL;
374
			char *tmp_cur;
361
		uint32_t save_task_id = 0;
375
			if (!end_ptr)
362
		if (!_het_job_offset_match(job_ptr, het_job_offset))
376
				tmp_cur = job_id_str;
363
			continue;
377
			else
364
		if (!_task_id_in_job(job_ptr, array_id))
378
				tmp_cur = end_ptr + 1;
365
			continue;
379
366
		if ((array_id != NO_VAL) && job_ptr->array_task_str) {
380
			job_id = (uint32_t) strtol (tmp_cur, &end_ptr, 10);
367
			save_array_str = job_ptr->array_task_str;
381
			if (end_ptr[0] == '_')
368
			job_ptr->array_task_str = NULL;
382
				array_id = strtol(end_ptr + 1, &end_ptr, 10);
369
			save_task_id = job_ptr->array_task_id;
383
			if (end_ptr[0] == '+')
370
			job_ptr->array_task_id = array_id;
384
				het_job_offset = strtol(end_ptr + 1, &end_ptr, 10);
371
		}
385
		}
372
		slurm_print_job_info(stdout, job_ptr, one_liner);
386
373
		if (save_array_str) {
387
		for (i = 0, job_ptr = job_buffer_ptr->job_array;
374
			job_ptr->array_task_str = save_array_str;
388
			i < job_buffer_ptr->record_count; i++, job_ptr++) {
375
			job_ptr->array_task_id = save_task_id;
389
			char *save_array_str = NULL;
390
			uint32_t save_task_id = 0;
391
			if (exp_cnt && !_job_id_match(job_ptr, job_id))
392
				continue;
393
			if (!_het_job_offset_match(job_ptr, het_job_offset))
394
				continue;
395
			if (!_task_id_in_job(job_ptr, array_id))
396
				continue;
397
			if ((array_id != NO_VAL) && job_ptr->array_task_str) {
398
				save_array_str = job_ptr->array_task_str;
399
				job_ptr->array_task_str = NULL;
400
				save_task_id = job_ptr->array_task_id;
401
				job_ptr->array_task_id = array_id;
402
			}
403
			slurm_print_job_info(stdout, job_ptr, one_liner);
404
			if (save_array_str) {
405
				job_ptr->array_task_str = save_array_str;
406
				job_ptr->array_task_id = save_task_id;
407
			}
408
			print_cnt++;
376
		}
409
		}
377
		print_cnt++;
410
	} while (end_ptr && *end_ptr != '\0');
378
	}
379
411
380
	if (print_cnt == 0) {
412
	if (print_cnt < exp_cnt + 1) {
381
		if (job_id_str) {
413
		if(exp_cnt) {
382
			exit_code = 1;
414
			int missing = exp_cnt + 1 - print_cnt;
383
			if (quiet_flag != 1) {
415
			if (missing == 1)
384
				if (array_id != NO_VAL) {
416
				printf ("One job has not been found\n");
385
					printf("Job %u_%u not found\n",
417
			else
386
					       job_id, array_id);
418
				printf ("%d jobs have not been found\n", missing);
387
				} else if (het_job_offset != NO_VAL) {
419
		} else {
388
					printf("Job %u+%u not found\n",
420
			if (job_id_str) {
389
					       job_id, het_job_offset);
421
				exit_code = 1;
390
				} else {
422
				if (quiet_flag != 1) {
391
					printf("Job %u not found\n", job_id);
423
					if (array_id != NO_VAL) {
424
						printf("Job %u_%u not found\n",
425
							job_id, array_id);
426
					} else if (het_job_offset != NO_VAL) {
427
						printf("Job %u+%u not found\n",
428
							job_id, het_job_offset);
429
					} else {
430
						printf("Job %u not found\n", job_id);
431
					}
392
				}
432
				}
393
			}
433
			} else if (quiet_flag != 1)
394
		} else if (quiet_flag != 1)
434
				printf ("No jobs in the system\n");
395
			printf ("No jobs in the system\n");
435
		}
396
	}
436
	}
397
}
437
}
398
438

Return to ticket 9056