Hadoop Common
  1. Hadoop Common
  2. HADOOP-6702

Incorrect exit codes for "dfs -chown", "dfs -chgrp" when input is given in wildcard format.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.19.1, 0.20.0, 0.20.1, 0.20.2
    • Fix Version/s: 0.20.3, 0.21.0, 0.22.0
    • Component/s: fs
    • Labels:
      None

      Description

      Currently incorrect exit codes are given for "dfs -chown", "dfs -chgrp" when input is given in wildcard format.

      This bug is due to missing update of errors count in FsShell.java.

      FsShell.java
      int runCmdHandler(CmdHandler handler, String[] args,
                                         int startIndex, boolean recursive) 
                                         throws IOException {
          int errors = 0;
          
          for (int i=startIndex; i<args.length; i++) {
            Path srcPath = new Path(args[i]);
            FileSystem srcFs = srcPath.getFileSystem(getConf());
            Path[] paths = FileUtil.stat2Paths(srcFs.globStatus(srcPath), srcPath);
            for(Path path : paths) {
              try {
                FileStatus file = srcFs.getFileStatus(path);
                if (file == null) {
                  System.err.println(handler.getName() + 
                                     ": could not get status for '" + path + "'");
                  errors++;
                } else {
                  errors += runCmdHandler(handler, file, srcFs, recursive);
                }
              } catch (IOException e) {
                String msg = (e.getMessage() != null ? e.getLocalizedMessage() :
                  (e.getCause().getMessage() != null ? 
                      e.getCause().getLocalizedMessage() : "null"));
                System.err.println(handler.getName() + ": could not get status for '"
                                              + path + "': " + msg.split("\n")[0]);
                errors++;
              }
            }
          }
       

      If there are no files on HDFS matching to wildcard input then srcFs.globStatus(srcpath) returns 0.
      {{ Path[] paths = FileUtil.stat2Paths(srcFs.globStatus(srcPath), srcPath);}}

      Resulting no increment in errors and command exits with 0 even though file/directory does not exist.

        Issue Links

          Activity

          Ravi Phulari created issue -
          Ravi Phulari made changes -
          Field Original Value New Value
          Link This issue relates to HADOOP-6701 [ HADOOP-6701 ]
          Ravi Phulari made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Tom White made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Daryn Sharp made changes -
          Link This issue requires HDFS-1736 [ HDFS-1736 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development