Salome HOME
Implement some system limits on jobs launched by LOCAL job manager
authorbarate <barate>
Fri, 18 Jan 2013 17:00:23 +0000 (17:00 +0000)
committerbarate <barate>
Fri, 18 Jan 2013 17:00:23 +0000 (17:00 +0000)
src/Core/Constants.cxx
src/Core/Constants.hxx
src/Core/ParameterTypeMap.cxx
src/Local/BatchManager_Local.cxx

index 602b7257a020b65649b18dd7bf800b97f7e91ff6..c6df750b784693949874be01e06f0f715ae1ffa6 100644 (file)
@@ -44,11 +44,9 @@ namespace Batch {
   def_Constant(NBPROC);
   def_Constant(NBPROCPERNODE);
   def_Constant(OUTFILE);
-  def_Constant(PID);
   def_Constant(QUEUE);
   def_Constant(STATE);
   def_Constant(WORKDIR);
-  def_Constant(HOMEDIR);
   def_Constant(EXCLUSIVE);
 
   // These constants define the status of a job (parameter STATE);
index 648ab0650b80266640cc05165040e187d10593c1..46cbaf1151599d7a234606523366521de0297b43 100644 (file)
@@ -55,11 +55,9 @@ namespace Batch {
   decl_extern_Constant(NBPROC);
   decl_extern_Constant(NBPROCPERNODE);
   decl_extern_Constant(OUTFILE);
-  decl_extern_Constant(PID);
   decl_extern_Constant(QUEUE);
   decl_extern_Constant(STATE);
   decl_extern_Constant(WORKDIR);
-  decl_extern_Constant(HOMEDIR);
   decl_extern_Constant(EXCLUSIVE);
 
   // These constants define the status of a job (parameter STATE)
index 0622583e68ccd76fea29ff4cb35a0c432b897d31..0e5973d11dfbf7ebeafc2d3d1e2221d8362f337a 100644 (file)
@@ -57,11 +57,9 @@ namespace Batch {
     addParameter("NBPROC", LONG, 1);
     addParameter("NBPROCPERNODE", LONG, 1);
     addParameter("OUTFILE", COUPLE, 0);
-    addParameter("PID", LONG, 1);
     addParameter("QUEUE", STRING, 1);
     addParameter("STATE", STRING, 1);
     addParameter("WORKDIR", STRING, 1);
-    addParameter("HOMEDIR", STRING, 1);
     addParameter("EXCLUSIVE", BOOL, 1);
   }
 
index 83530bcbed0a9b4136fd90999a67b949006101ba..e47a42a609ab8def2c87c053ce4d8fec6ae7dbbe 100644 (file)
@@ -305,11 +305,21 @@ namespace Batch {
     tempOutputFile << "#!/bin/sh" << endl;
     tempOutputFile << "cd " << workDir << endl;
 
-    // Optional parameters
-    //if (param.find(MAXWALLTIME) != param.end())
-    //  tempOutputFile << "#SBATCH --time=" << param[MAXWALLTIME] << endl;
-    //if (param.find(MAXRAMSIZE) != param.end())
-    //  tempOutputFile << "#SBATCH --mem=" << param[MAXRAMSIZE] << endl;
+    // Optional parameters (system limits on the job process)
+    if (param.find(MAXCPUTIME) != param.end()) {
+      long maxcputime = (long)param[MAXCPUTIME] * 60;
+      tempOutputFile << "ulimit -H -t " << maxcputime << endl;
+    }
+
+    if (param.find(MAXDISKSIZE) != param.end()) {
+      long maxdisksize = (long)param[MAXDISKSIZE] * 1024;
+      tempOutputFile << "ulimit -H -f " << maxdisksize << endl;
+    }
+
+    if (param.find(MAXRAMSIZE) != param.end()) {
+      long maxramsize = (long)param[MAXRAMSIZE] * 1024;
+      tempOutputFile << "ulimit -H -v " << maxramsize << endl;
+    }
 
     // Define environment for the job
     Environnement env = job.getEnvironnement();
@@ -493,9 +503,6 @@ namespace Batch {
     id_sst << _id;
     param[ID]         = id_sst.str();
     param[STATE]      = Batch::RUNNING;
-#ifndef WIN32
-    param[PID]        = child;
-#endif
 
     _bm._threads[_id].thread_id = thread_id;
 #ifndef WIN32
@@ -691,35 +698,6 @@ namespace Batch {
       argv[command.size()] = NULL;
       UNDER_LOCK( cout << "*** debug_command = " << comstr << endl );
 
-      // On positionne les limites systeme imposees au fils
-      // This part is deactivated because those limits should be set on the job process, not on
-      // the ssh process. If it is done properly one day, beware of the types used (int is not enough)
-      /*
-      if (param.find(MAXCPUTIME) != param.end()) {
-        int maxcputime = param[MAXCPUTIME];
-        struct rlimit limit;
-        limit.rlim_cur = maxcputime;
-        limit.rlim_max = int(maxcputime * 1.1);
-        setrlimit(RLIMIT_CPU, &limit);
-      }
-
-      if (param.find(MAXDISKSIZE) != param.end()) {
-        int maxdisksize = param[MAXDISKSIZE];
-        struct rlimit limit;
-        limit.rlim_cur = maxdisksize * 1024;
-        limit.rlim_max = int(maxdisksize * 1.1) * 1024;
-        setrlimit(RLIMIT_FSIZE, &limit);
-      }
-
-      if (param.find(MAXRAMSIZE) != param.end()) {
-        int maxramsize = param[MAXRAMSIZE];
-        struct rlimit limit;
-        limit.rlim_cur = maxramsize * 1024 * 1024;
-        limit.rlim_max = int(maxramsize * 1.1) * 1024 * 1024;
-        setrlimit(RLIMIT_AS, &limit);
-      }
-      */
-
       // On cree une session pour le fils de facon a ce qu'il ne soit pas
       // detruit lorsque le shell se termine (le shell ouvre une session et
       // tue tous les process appartenant a la session en quittant)