From 90b866ea2b93f9186651fd540d91bdcc9a3abbc1 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 29 Jan 2020 19:40:57 +0100 Subject: [PATCH 1/3] mxqd: Use environment MXQ_JOB_TMPDIR It might be usefull for a script to know, if it has a job-specific temporary filesystem or not. If the job was submitted with --tmpdir then set both MXQ_JOB_TMPDIR and TMPDIR to the path of the temporary space. If a program is run without --tmpdir or outside of mxqd, then TMPDIR usually points to some (non-private) temporary space as well, but MXQ_JOB_TMPDIR will not be set. --- mxqd.c | 6 +++++- mxqsub.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mxqd.c b/mxqd.c index 412e43e3..aef3ab0d 100644 --- a/mxqd.c +++ b/mxqd.c @@ -791,7 +791,11 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job) if (group->job_tmpdir_size == 0) { mx_setenv_forever("TMPDIR", server->initial_tmpdir); } else { - mx_setenvf_forever("TMPDIR", "%s/%lu", MXQ_JOB_TMPDIR_MNTDIR, job->job_id); + char *mxq_job_tmpdir; + mx_asprintf_forever(&mxq_job_tmpdir, "%s/%lu", MXQ_JOB_TMPDIR_MNTDIR, job->job_id); + mx_setenv_forever("MXQ_JOB_TMPDIR", mxq_job_tmpdir); + mx_setenv_forever("TMPDIR", mxq_job_tmpdir); + free(mxq_job_tmpdir); } fh = open("/proc/self/loginuid", O_WRONLY|O_TRUNC); if (fh == -1) { diff --git a/mxqsub.c b/mxqsub.c index f9c62b05..e9900d11 100644 --- a/mxqsub.c +++ b/mxqsub.c @@ -71,7 +71,7 @@ static void print_usage(void) "\n" " -j, --threads=NUMBER set number of threads (default: 1)\n" " -m, --memory=SIZE set amount of memory (default: 2G)\n" - " --tmpdir=SIZE set size of TMPDIR (default: 0)\n" + " --tmpdir=SIZE set size of MXQ_JOB_TMPDIR (default: 0)\n" "\n" " [SIZE] may be suffixed with a combination of T, G and M\n" " to specify tebibytes, gibibytes and mebibytes.\n" From 9d625a27ebfb2b89ddf0ea21ec7f35fbd748c97d Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 29 Jan 2020 20:07:58 +0100 Subject: [PATCH 2/3] web: Fix hrefs when called without path_info If the cgi-scripts was references without path-info e.g. http://server/path/script instead of http://server/path/script/ than wrong self-referencing urls are created, because the last path component is replaces by the module ("/groups","/server" or "/active_jobs"). Reuse existings selfurl() function to generate the self-referencing urls. This function replaces the path_info, not the last path component. --- web/pages/mxq/mxq.in | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/pages/mxq/mxq.in b/web/pages/mxq/mxq.in index 71a166a9..2356aea1 100755 --- a/web/pages/mxq/mxq.in +++ b/web/pages/mxq/mxq.in @@ -40,10 +40,14 @@ sub HEAD { return "\n\n".STYLE()."\n"; } +sub selfurl { + my ($path_info)=@_; + return $q->url().$path_info; +} + sub my_url { my ($module,$params)=@_; - - my $uri=new URI($module,$q->url()); + my $uri=new URI(selfurl("/$module")); $uri->query_form($params,';'); return $uri; } @@ -862,11 +866,6 @@ sub server() { return $out; } -sub selfurl { - my ($path_info)=@_; - return $q->url().$path_info; -} - sub top_menu { return '' . $q->Tr( $q->td(a({href=>selfurl('/groups')},'groups')),$q->td(' '), From 0473d020a259f405c5b24ae35b7585d245d8c096 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 29 Jan 2020 20:24:23 +0100 Subject: [PATCH 3/3] web: Don't show "0 GB" in group table If no tmpdir was requested, show "-" in the "req.tmpdir" column instead of "0 GB". --- web/pages/mxq/mxq.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pages/mxq/mxq.in b/web/pages/mxq/mxq.in index 2356aea1..8a7bca74 100755 --- a/web/pages/mxq/mxq.in +++ b/web/pages/mxq/mxq.in @@ -647,7 +647,7 @@ sub group_table { $q->td({class=>'number'},$job_threads), $q->td({class=>'number'},size($job_memory*1000**2)), $q->td({class=>'number'},days($job_time*60)), - $q->td({class=>'number'},size($job_tmpdir_size*1000*1000*1000)), + $q->td({class=>'number'}, $job_tmpdir_size ? size($job_tmpdir_size*1000*1000*1000) : '-'), $q->td($q->a({href=>my_url('groups',{user_name=>$user_name})},$user_name)), $q->td(group_status($group_status)), $q->td({class=>'number'},$group_jobs),