You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/04/28 22:05:27 UTC

[GitHub] [hadoop] smengcl commented on a change in pull request #2927: HDFS-15982. Deleted data using HTTP API should be saved to the trash

smengcl commented on a change in pull request #2927:
URL: https://github.com/apache/hadoop/pull/2927#discussion_r622590087



##########
File path: hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java
##########
@@ -743,6 +748,15 @@ public FSDelete(String path, boolean recursive) {
      */
     @Override
     public JSONObject execute(FileSystem fs) throws IOException {
+      if (!skipTrash) {
+        boolean movedToTrash = Trash.moveToAppropriateTrash(fs, path,
+            fs.getConf());
+        if (movedToTrash) {
+          HttpFSServerWebApp.getMetrics().incrOpsDelete();
+          return toJSON(
+              StringUtils.toLowerCase(HttpFSFileSystem.DELETE_JSON), true);
+        }

Review comment:
       IIUC the condition here implies when `Trash.moveToAppropriateTrash` [returns false](https://github.com/apache/hadoop/blob/1e3a6efcef2924a7966c44ca63476c853956691d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java#L123-L125) (**but doesn't throw**), we are automatically attempting to delete the target permanently **instead**.
   
   Nice trick, but we should document this in the code. Please put some code comment here.
   
   If `moveToAppropriateTrash` throws (e.g. `Failed to move to trash`, happens when the user's trash dir doesn't exist and the user doesn't have permission), it wouldn't reach the condition.

##########
File path: hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/DeleteSkipTrashParam.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.web.resources;
+
+/**
+ * SkipTrash param to be used by DELETE query.
+ */
+public class DeleteSkipTrashParam extends BooleanParam {
+
+  public static final String NAME = "skiptrash";
+  public static final String DEFAULT = FALSE;

Review comment:
       We should set the WebHDFS delete skiptrash default to `true` imo in order to behave the same with previous versions. This can be an unexpected behavior change when a cluster/client is upgraded. This means if a WebHDFS client doesn't want skiptrash it should explicitly state `skiptrash=false`.
   
   I can understand `skiptrash=false` is the default for CLI, but for WebHDFS it can be seen as implicit `skiptrash=true` since the beginning (and is the norm for WebHDFS users).
   
   Thoughts?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org