Github user steveloughran commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14371#discussion_r72426474
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala 
---
    @@ -404,6 +404,27 @@ class SparkHadoopUtil extends Logging {
         }
         buffer.toString
       }
    +
    +  /**
    +   * Delete a directory if it exists. If the `FileSystem.delete` operation 
returns false,
    +   * the path is checked for existence. If it is still there, a warning is 
printed.
    +   * @param fs filesystem
    +   * @param path path to delete
    +   * @param recursive recursive flag
    +   * @return true if there is no file/directory at the end of the path. 
That is: the delete worked.
    +   */
    +  def delete(fs: FileSystem, path: Path, recursive: Boolean): Boolean = {
    +    if (!fs.delete(path, recursive)) {
    +      if (fs.exists(path)) {
    +        logWarning(s"Error deleting $path")
    +        false
    +      } else {
    +        true
    +      }
    +    } else {
    +      true
    --- End diff --
    
    With one special exception, In all the ASF Hadoop FS implementations (HDFS, 
local, s3{,a,n}, azure,swift, when delete() completes it means the destination 
is no longer there. Failures: permissions, dir not empty, etc: all thrown in 
exceptions.
    
    The special case: is root directories. HDFS doesn't support rm -rf /; S3A 
(currently) replicates this policy, though that may change soon. That' the only 
case where `!delete(path) && exists(path)` will hold. In the Hive cleanup we 
stripped out the handling; I'm also doing that for Hadoop itself. So, using 
fs.delete() everywhere should make sense. I just pulled this out so that there 
was one consistent codepath...relying on fs.delete() to simply work as 
described should suffice


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to