From b111679de1fb65f69fa72ca8471851252729997d Mon Sep 17 00:00:00 2001 From: barate Date: Fri, 18 Jan 2013 17:00:23 +0000 Subject: [PATCH] Implement some system limits on jobs launched by LOCAL job manager --- src/Core/Constants.cxx | 2 -- src/Core/Constants.hxx | 2 -- src/Core/ParameterTypeMap.cxx | 2 -- src/Local/BatchManager_Local.cxx | 52 +++++++++----------------------- 4 files changed, 15 insertions(+), 43 deletions(-) diff --git a/src/Core/Constants.cxx b/src/Core/Constants.cxx index 602b725..c6df750 100644 --- a/src/Core/Constants.cxx +++ b/src/Core/Constants.cxx @@ -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); diff --git a/src/Core/Constants.hxx b/src/Core/Constants.hxx index 648ab06..46cbaf1 100644 --- a/src/Core/Constants.hxx +++ b/src/Core/Constants.hxx @@ -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) diff --git a/src/Core/ParameterTypeMap.cxx b/src/Core/ParameterTypeMap.cxx index 0622583..0e5973d 100644 --- a/src/Core/ParameterTypeMap.cxx +++ b/src/Core/ParameterTypeMap.cxx @@ -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); } diff --git a/src/Local/BatchManager_Local.cxx b/src/Local/BatchManager_Local.cxx index 83530bc..e47a42a 100644 --- a/src/Local/BatchManager_Local.cxx +++ b/src/Local/BatchManager_Local.cxx @@ -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) -- 2.39.2