Hadoop Common
  1. Hadoop Common
  2. HADOOP-6143

FS shell commands returns incorrect exit code when error occurs

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: fs
    • Labels:
      None

      Description

      HDFS documentation ( http://hadoop.apache.org/core/docs/current/hdfs_shell.html#du ) mentions that

      Exit Code:
      
      Returns 0 on success and -1 on error. 
      

      Current Fs shell behavior is buggy with this agreement.

      statepick-lm:Hadoop rphulari$ bin/hadoop fs -ls foo
      ls: Cannot access foo: No such file or directory.
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -lsr foo
      lsr: Cannot access foo: No such file or directory.
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -du foo
      du: Cannot access foo: No such file or directory.
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -dus foo
      dus: Cannot access foo: No such file or directory.
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -cp foo f2
      cp: File does not exist: foo
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -copyToLocal foo f2
      copyToLocal: null
      statepick-lm:Hadoop rphulari$ echo $?
      255
      statepick-lm:Hadoop rphulari$ bin/hadoop fs -copyFromLocal foo f2
      copyFromLocal: File foo does not exist.
      statepick-lm:Hadoop rphulari$ echo $?
      255
      

      In all above cases exit code on error should be -1

      1. HADOOP-6143.patch
        10 kB
        Ravi Phulari
      2. HADOOP-6143-1.patch
        9 kB
        Ravi Phulari

        Issue Links

          Activity

          Hide
          Chris Douglas added a comment -
          -		   <code> Returns 0 on success and -1 on error. </code></p>
          +		   <code> Returns 0 on success , and >0 if an error occurs. </code></p>
          

          Rather than test- or care- whether other platforms return -1, I would prefer "nonzero on error" or more symmetrically, "nonzero on failure".

          Show
          Chris Douglas added a comment - - <code> Returns 0 on success and -1 on error. </code></p> + <code> Returns 0 on success , and >0 if an error occurs. </code></p> Rather than test- or care- whether other platforms return -1, I would prefer "nonzero on error" or more symmetrically, "nonzero on failure".
          Hide
          Hadoop QA added a comment -

          -1 overall. Here are the results of testing the latest attachment
          http://issues.apache.org/jira/secure/attachment/12413189/HADOOP-6143.patch
          against trunk revision 793162.

          +1 @author. The patch does not contain any @author tags.

          -1 tests included. The patch doesn't appear to include any new or modified tests.
          Please justify why no new tests are needed for this patch.
          Also please list what manual steps were performed to verify this patch.

          +1 javadoc. The javadoc tool did not generate any warning messages.

          +1 javac. The applied patch does not increase the total number of javac compiler warnings.

          +1 findbugs. The patch does not introduce any new Findbugs warnings.

          +1 release audit. The applied patch does not increase the total number of release audit warnings.

          +1 core tests. The patch passed core unit tests.

          +1 contrib tests. The patch passed contrib unit tests.

          Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/testReport/
          Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
          Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/artifact/trunk/build/test/checkstyle-errors.html
          Console output: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/console

          This message is automatically generated.

          Show
          Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12413189/HADOOP-6143.patch against trunk revision 793162. +1 @author. The patch does not contain any @author tags. -1 tests included. The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/testReport/ Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/artifact/trunk/build/test/checkstyle-errors.html Console output: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch-vesta.apache.org/569/console This message is automatically generated.
          Hide
          Ravi Phulari added a comment -

          This patch consists of only documentation changes . Compiled ant docs and verified HTML docs .
          No Tests included .

          Show
          Ravi Phulari added a comment - This patch consists of only documentation changes . Compiled ant docs and verified HTML docs . No Tests included .
          Hide
          Ravi Phulari added a comment -

          Attaching patch .

          Show
          Ravi Phulari added a comment - Attaching patch .
          Hide
          Ravi Phulari added a comment -

          +1 For changing the docs .

          Show
          Ravi Phulari added a comment - +1 For changing the docs .
          Hide
          Jakob Homan added a comment -

          we should correct documentation as "exit code returns non zero value on error"

          +1

          Show
          Jakob Homan added a comment - we should correct documentation as "exit code returns non zero value on error" +1
          Hide
          Todd Lipcon added a comment -
          todd@todd-laptop:/tmp$ cat Test.java 
          public class Test {
            public static void main(String []args) {
              System.exit(-1);
            }
          }
          todd@todd-laptop:/tmp$ javac Test.java 
          todd@todd-laptop:/tmp$ java -cp . Test ; echo $?
          255
          

          It's possible this might actually return -1 on some other OS though (does Windows have a concept of an exit code? I think maybe?). Changing the docs to say "nonzero" vs "zero" instead of -1 vs 0 does make sense, though.

          Show
          Todd Lipcon added a comment - todd@todd-laptop:/tmp$ cat Test.java public class Test { public static void main( String []args) { System .exit(-1); } } todd@todd-laptop:/tmp$ javac Test.java todd@todd-laptop:/tmp$ java -cp . Test ; echo $? 255 It's possible this might actually return -1 on some other OS though (does Windows have a concept of an exit code? I think maybe?). Changing the docs to say "nonzero" vs "zero" instead of -1 vs 0 does make sense, though.
          Hide
          Ravi Phulari added a comment -

          As I wrote in the above description HDFS shell guide misleads to user that exit code -1 is returned on error.
          ( http://hadoop.apache.org/core/docs/current/hdfs_shell.html#du )
          Either we should return exact exit value equal to -1 on error or we should correct documentation as "exit code returns non zero value on error"

          OS X manual for CP command explicitly mentions that "cp utility exits >0 if an error occurs"

          statepick-lm:hadoop-hdfs rphulari$ man cp | grep exit
                     is displayed and the exit value is not altered.
               The cp utility exits 0 on success, and >0 if an error occurs.
          
          Show
          Ravi Phulari added a comment - As I wrote in the above description HDFS shell guide misleads to user that exit code -1 is returned on error. ( http://hadoop.apache.org/core/docs/current/hdfs_shell.html#du ) Either we should return exact exit value equal to -1 on error or we should correct documentation as "exit code returns non zero value on error" OS X manual for CP command explicitly mentions that "cp utility exits >0 if an error occurs" statepick-lm:hadoop-hdfs rphulari$ man cp | grep exit is displayed and the exit value is not altered. The cp utility exits 0 on success, and >0 if an error occurs.
          Hide
          Todd Lipcon added a comment -

          Resolving as invalid. Please reopen if you disagree.

          Show
          Todd Lipcon added a comment - Resolving as invalid. Please reopen if you disagree.
          Hide
          Todd Lipcon added a comment -

          -1 exit code is equivalent to 255 exit code on Linux - exit codes are a single byte and range from 0-255. See http://www.faqs.org/docs/abs/HTML/exit-status.html

          Show
          Todd Lipcon added a comment - -1 exit code is equivalent to 255 exit code on Linux - exit codes are a single byte and range from 0-255. See http://www.faqs.org/docs/abs/HTML/exit-status.html

            People

            • Assignee:
              Ravi Phulari
              Reporter:
              Ravi Phulari
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Development