From b744d931fbd9b35df7bec3cf537de50219ce4874 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 19 Jun 2009 20:03:01 +0000
Subject: [PATCH] salloc's --wait=<secs> option deprecated by
 --immediate=<secs> option to     match the srun command.

---
 NEWS                      |  2 ++
 doc/man/man1/salloc.1     |  7 +------
 src/salloc/opt.c          | 17 +++++------------
 src/salloc/opt.h          |  1 -
 testsuite/expect/test15.8 | 16 +++++++++++-----
 5 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/NEWS b/NEWS
index cf475475db9..70784df014f 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ documents those changes that are of interest to users and admins.
  -- ALTERED API CALL slurm_get_job_steps 0 has been changed to NO_VAL for both
     job and step id to recieve all jobs/steps.  Please make adjustments to
     your code.
+ -- salloc's --wait=<secs> option deprecated by --immediate=<secs> option to 
+    match the srun command.
 
 * Changes in SLURM 2.1.0-pre1
 =============================
diff --git a/doc/man/man1/salloc.1 b/doc/man/man1/salloc.1
index 51088bf9dd3..1b030f15d0e 100644
--- a/doc/man/man1/salloc.1
+++ b/doc/man/man1/salloc.1
@@ -756,12 +756,7 @@ errors will be displayed.
 
 .TP
 \fB\-W\fR, \fB\-\-wait\fR=<\fIseconds\fR>
-If the resources needed to satisy a job allocation are not immediately
-available, the job allocation is enqueued and is said to be PENDING.  This
-option tells salloc how long (in seconds) to wait for the allocation to be
-granted before giving up.  When the wait limit has been reached, salloc
-will exit without running the \fIcommand\fR parameter.  By default, salloc
-will wait indefinitely.  (The \-\-immediate option makes \-\-wait moot.)
+This option has been replaced by \fB\-\-immediate\fR=<\fIseconds\fR>.
 
 .TP
 \fB\-w\fR, \fB\-\-nodelist\fR=<\fInode name list\fR>
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index 62ca9a98e7c..3a9450654ed 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -275,7 +275,6 @@ static void _opt_default()
 
 	opt.immediate	= 0;
 	opt.overcommit	= false;
-	opt.max_wait	= 0;
 
 	opt.quiet = 0;
 	opt.verbose = 0;
@@ -349,7 +348,7 @@ env_vars_t env_vars[] = {
   {"SALLOC_OVERCOMMIT",    OPT_OVERCOMMIT, NULL,               NULL          },
   {"SALLOC_PARTITION",     OPT_STRING,     &opt.partition,     NULL          },
   {"SALLOC_TIMELIMIT",     OPT_STRING,     &opt.time_limit_str,NULL          },
-  {"SALLOC_WAIT",          OPT_INT,        &opt.max_wait,      NULL          },
+  {"SALLOC_WAIT",          OPT_IMMEDIATE,  NULL,               NULL          },
   {"SALLOC_WCKEY",         OPT_STRING,     &opt.wckey,         NULL          },
   {NULL, 0, NULL, NULL}
 };
@@ -670,7 +669,7 @@ void set_options(const int argc, char **argv)
 			break;
 		case 'I':
 			if (optarg)
-				opt.immediate = strtol(optarg, NULL, 10);
+				opt.immediate = _get_int(optarg, "immediate");
 			else
 				opt.immediate = DEFAULT_IMMEDIATE;
 			break;
@@ -769,7 +768,9 @@ void set_options(const int argc, char **argv)
 #endif
 			break;
 		case 'W':
-			opt.max_wait = _get_int(optarg, "wait");
+			verbose("wait option has been deprecated, use "
+				"immediate option");
+			opt.immediate = _get_int(optarg, "wait");
 			break;
 		case 'x':
 			xfree(opt.exc_nodes);
@@ -1313,11 +1314,6 @@ static bool _opt_verify(void)
 			opt.ntasks_per_node);
 	}
 
-	if (opt.max_wait) {
-		/* FIXME: Eliminate max_wait in slurm v2.1 */
-		opt.immediate = MAX(opt.immediate, opt.max_wait);
-	}
-
 	return verified;
 }
 
@@ -1554,7 +1550,6 @@ static void _opt_list()
 		info("time_limit     : INFINITE");
 	else if (opt.time_limit != NO_VAL)
 		info("time_limit     : %d", opt.time_limit);
-	info("wait           : %d", opt.max_wait);
 	if (opt.nice)
 		info("nice           : %d", opt.nice);
 	info("account        : %s", opt.account);
@@ -1687,8 +1682,6 @@ static void _help(void)
 "  -U, --account=name          charge job to specified account\n"
 "      --uid=user_id           user ID to run job as (user root only)\n"
 "  -v, --verbose               verbose mode (multiple -v's increase verbosity)\n"
-"  -W, --wait=sec              seconds to wait for allocation if not\n"
-"                              immediately available\n"
 "\n"
 "Constraint options:\n"
 "      --contiguous            demand a contiguous range of nodes\n"
diff --git a/src/salloc/opt.h b/src/salloc/opt.h
index 3175f0d4842..3fbfd6d297f 100644
--- a/src/salloc/opt.h
+++ b/src/salloc/opt.h
@@ -103,7 +103,6 @@ typedef struct salloc_options {
 	int kill_command_signal;/* --kill-command, -K           */
 	bool kill_command_signal_set;
 	uint16_t shared;	/* --share,   -s		*/
-	int  max_wait;		/* --wait,    -W		*/
 	int  quiet;
 	int  verbose;
 
diff --git a/testsuite/expect/test15.8 b/testsuite/expect/test15.8
index 5ecca86b08a..8ab9e5b4521 100755
--- a/testsuite/expect/test15.8
+++ b/testsuite/expect/test15.8
@@ -43,13 +43,18 @@ print_header $test_id
 # The job can't run immediately with a priority of zero
 #
 set timeout 10
-set salloc_pid [spawn $salloc --immediate --hold -t1 -v $bin_pwd]
+set salloc_pid [spawn $salloc --immediate=3 --hold -t1 -v $bin_pwd]
 expect {
 	-re "Pending job allocation ($number)" {
 		set job_id $expect_out(1,string)
+		incr matches
+		exp_continue
+	}
+	-re "queued and waiting for resources" {
+		incr matches
 		exp_continue
 	}
-	-re "Failed to allocate resources" {
+	-re "Unable to allocate resources" {
 		send_user "This error is expected, no worries\n"
 		incr matches
 		exp_continue
@@ -66,12 +71,13 @@ expect {
 		wait
 	}
 }
-if {$matches != 1} {
-	send_user "\nFAILURE: failed to hold job as requested\n"
+if {$matches != 3} {
+	send_user "\nFAILURE: failed to hold job as requested ($matches != 3)\n"
 	set exit_code 1
+} else {
+	send_user "\nSo far, so good\n\n"
 }
 
-
 #
 # Spawn a salloc immediate execution job, it should run or fail immediately
 # Note the small value of timeout
-- 
GitLab