From ebbf58a5ccd2897b09fb81f33cf1fb9cf96319de Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Fri, 21 Oct 2011 13:42:18 -0700
Subject: [PATCH] Set job time limit to max value within partition limit

If job time limit exceeds partition maximum, but job's minimum time limit
does not, set job's time limit to partition maximum at allocation time.
---
 NEWS                           | 2 ++
 src/slurmctld/job_mgr.c        | 1 +
 src/slurmctld/node_scheduler.c | 6 +++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 79556974710..5a5f6ac6afd 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,8 @@ documents those changes that are of interest to users and admins.
  -- Fixed issue where if a job ended with ESLURMD_UID_NOT_FOUND and
     ESLURMD_GID_NOT_FOUND where slurm would be a little over zealous
     in treating missing a GID or UID as a fatal error.
+ -- If job time limit exceeds partition maximum, but job's minimum time limit
+    does not, set job's time limit to partition maximum at allocation time.
 
 * Changes in SLURM 2.3.1
 ========================
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index dadcbb77c5c..5cbd88fdd8b 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -3745,6 +3745,7 @@ extern int job_limits_check(struct job_record **job_pptr)
 		fail_reason = WAIT_PART_INACTIVE;
 	} else if ((job_ptr->time_limit != NO_VAL) &&
 		   ((job_ptr->time_limit > part_ptr->max_time) &&
+		    (job_ptr->time_min   > part_ptr->max_time) &&
 		    (!qos_ptr || (qos_ptr && !(qos_ptr->flags &
 					       QOS_FLAG_PART_TIME_LIMIT))))) {
 		info("Job %u exceeds partition time limit", job_ptr->job_id);
diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c
index 29c74a6aa2c..66fb6f86bbc 100644
--- a/src/slurmctld/node_scheduler.c
+++ b/src/slurmctld/node_scheduler.c
@@ -1205,6 +1205,7 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 		fail_reason = WAIT_HELD;
 	else if ((job_ptr->time_limit != NO_VAL) &&
 		 ((job_ptr->time_limit > part_ptr->max_time) &&
+		  (job_ptr->time_min   > part_ptr->max_time) &&
 		  (!qos_ptr || (qos_ptr && !(qos_ptr->flags
 					     & QOS_FLAG_PART_TIME_LIMIT)))))
 		fail_reason = WAIT_PART_TIME_LIMIT;
@@ -1376,7 +1377,10 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 	 * is for the job when we place it
 	 */
 	job_ptr->start_time = job_ptr->time_last_active = now;
-	if (job_ptr->time_limit == NO_VAL) {
+	if ((job_ptr->time_limit == NO_VAL) ||
+	    ((job_ptr->time_limit > part_ptr->max_time) &&
+	     (!qos_ptr || (qos_ptr && !(qos_ptr->flags
+					& QOS_FLAG_PART_TIME_LIMIT))))) {
 		if (part_ptr->default_time != NO_VAL)
 			job_ptr->time_limit = part_ptr->default_time;
 		else
-- 
GitLab