#2449 ssh running xCAT command like tabdump -h from MN to SN hang

2.6.10
closed
General (881)
6
2012-09-19
2011-12-12
No

That code allows our plugins to get the stdin of the cmd that invoked the plugin. For example, when a user runs "cat mystanza | mkdef -z", the client cmd of mkdef grabs all the stdin data (in this case the stanza file) and stuffs it in the $cmdref->{stdin} variable to be passed to the plugin in xcatd. Of course, mkdef doesn't actually use xcatclient or xcatclientnnr, it sym links to a client cmd especially for the def cmds: xcatDBcmds. But it does essentially the same thing. But notice that in xcatDBcmds there is a special case for handling stdin for ksh on linux. (Looks like guang cheng put that in.) What that special case is doing is not just checking if STDIN is defined (which is what -p does), but does a select as a non-blocking way to see if there is any actual data in the STDIN file stream.

I did some checking on the machines you are having problems with, and some other machines, and it appears that when you run ssh with a cmd, on some machines it defines STDIN and some it doesn't. Yours it happens to. So why you are hanging is the -p check succeeds, so it thinks there is stdin data and it hangs in the "while (<STDIN>)" stmt. Actually, it isn't hanging. If you run your ssh test again, when it looks like it is hanging, it is just waiting for stdin. If you ctrl-d (eof), then it will finish.

So i think what we need to add to xcatclient, xcatclientnnr, and xcatDBcmds (and several other scripts that test -p STDIN in xCAT-client/bin) is a check if it is being run under ssh and, if so, do the select. We don't want to do the select all of the time, because it seems to add a second or 2 delay to the cmd. The only way i could figure out to test if we were running under ssh was to see if the TERM env var was not set. Anyone else know of a better way? For now, replacing the check with this in xcatclient, xcatclientnnr, and xcatDBcmds should fix your problem:

if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) )
{
my $rin="";
vec($rin,fileno(STDIN),1)=1;
my $nfound=select($rout=$rin,"","",1);
if ($nfound)
{
while ( <STDIN> ) { $data.=$; }
$cmdref->{stdin}->[0]=$data;
}
}
else
{
if (-p STDIN) {
while ( <STDIN> ) { $data.=$
; }
$cmdref->{stdin}->[0]=$data;
}
}

Discussion

  • Lissa Valletta

    Lissa Valletta - 2011-12-12

    Fixed in 2.6.10 with revision 11214
    Fixed in 2.7 with revision 11215

     
  • Lissa Valletta

    Lissa Valletta - 2011-12-12

    Fixed again in 2.6.10 revision 11216

     
  • Lissa Valletta

    Lissa Valletta - 2011-12-12

    And 2.7 revision 11218

     
  • Lissa Valletta

    Lissa Valletta - 2011-12-14
     
    Attachments
  • Lissa Valletta

    Lissa Valletta - 2011-12-14
     
    Attachments
  • Lissa Valletta

    Lissa Valletta - 2011-12-14
     
    Attachments
  • Lissa Valletta

    Lissa Valletta - 2011-12-14

    Efix files are attached below they should replace the following files on the EMS(MN) and Service Nodes. The daemon does not have to be restarted.
    /opt/xcat/bin/xcatclient, /opt/xcat/bin/xcatclientnnr,/opt/xcat/bin/xcatDBcmds.

     
  • Brian  Croswell

    Brian Croswell - 2012-02-17

    cleanup xcat bugs

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks