Patch for qsub stderr handling in linux_torque TSI

View: New views
2 Messages — Rating Filter:   Alert me  

Patch for qsub stderr handling in linux_torque TSI

by Troy Baer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

In our TORQUE environments, we have local policy enforcement code in the
submit filter that causes it to print informational messages to qsub's
stderr.  This confuses the default linux_torque TSI, as it combines
stdout and stderr from qsub and then interprets anything other than a
jobid in stdout as an error.  The attached patch fixes that behavior by
using IPC::Open3 rather than a backtick substitution to invoke qsub.

(There's a comment in the code to the effect that qsub returns 0 no
matter what.  I don't know if that was true at some point in the past,
but it does not appear to be true as of TORQUE 2.3.5.)

Regards,
        --Troy
--
Troy Baer, HPC System Administrator
National Institute for Computational Sciences, University of Tennessee
http://www.nics.tennessee.edu/
Phone:  865-241-4233

[Submit.pm.open3.diff]

--- Submit.pm.orig 2009-09-14 10:31:22.000000000 -0400
+++ Submit.pm 2009-09-15 15:19:11.000000000 -0400
@@ -7,7 +7,7 @@
 #                     and PBS by Achim Streit at Paderborn
 #
 ###############################################################################
-
+use IPC::Open3;
 require Exporter;
 @ISA = qw(Exporter);
 
@@ -225,11 +225,22 @@
  command_report($command);
 
  # and execute the command
- my $output = `($command) 2>&1`;
+                my $pid = open3(\*QSUBIN,\*QSUBOUT,\*QSUBERR,$command);
+                close(QSUBIN);
+                my $output = "";
+                while ( <QSUBOUT> ) {
+                   $output .= $_;
+                }
+                close(QSUBOUT);
+                my $err = "";
+                while ( <QSUBERR> ) {
+                    $err .= $_;
+                }
+                close(QSUBERR);
 
  # Parse output
  if($? != 0) {
- failed_report($output);
+ failed_report($output."\n".$err);
  }
  else {
 
@@ -247,10 +258,13 @@
  $res =~ s/[0-9]//g;
  if (length($res) == 0 ) {
  debug_report("Job submitted OK. Identifier: $jobid");
+                                        if ( $err ne "" ) {
+                                           debug_report($err);
+                                        }
  print main::CMD_SOCK "$jobid\n";
  }
  else {
- failed_report("Job submit failed?: $jobid $output");
+ failed_report("Job submit failed?: $jobid $output\n$err");
  }
  }
  else {


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Unicore-devel mailing list
Unicore-devel@...
https://lists.sourceforge.net/lists/listinfo/unicore-devel

Re: Patch for qsub stderr handling in linux_torque TSI

by Bernd Schuller :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi Troy,

thanks, this is very useful!

Best regards,
Bernd.

On Di, 2009-09-15 at 21:44 +0200, Troy Baer wrote:

> Hi all,
>
> In our TORQUE environments, we have local policy enforcement code in the
> submit filter that causes it to print informational messages to qsub's
> stderr.  This confuses the default linux_torque TSI, as it combines
> stdout and stderr from qsub and then interprets anything other than a
> jobid in stdout as an error.  The attached patch fixes that behavior by
> using IPC::Open3 rather than a backtick substitution to invoke qsub.
>
> (There's a comment in the code to the effect that qsub returns 0 no
> matter what.  I don't know if that was true at some point in the past,
> but it does not appear to be true as of TORQUE 2.3.5.)
>
> Regards,
>       --Troy
--
Dr. Bernd Schuller
Distributed Systems and Grid Computing
Juelich Supercomputing Centre, http://www.fz-juelich.de/jsc
Phone: +49 246161-8736 (fax -8556)
Personal blog: www.jroller.com/page/gridhaus


------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Unicore-devel mailing list
Unicore-devel@...
https://lists.sourceforge.net/lists/listinfo/unicore-devel