siddhantsangwan commented on code in PR #7976:
URL: https://github.com/apache/ozone/pull/7976#discussion_r1974955244


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/AbstractContainerReportHandler.java:
##########
@@ -352,26 +352,32 @@ private boolean updateContainerState(final 
DatanodeDetails datanode,
        */
       break;
     case DELETING:
+    case DELETED:
       /*
-      HDDS-11136: If a DELETING container has a non-empty CLOSED replica, the 
container should be moved back to CLOSED
-      state.
+       * HDDS-11136: If a DELETING container has a non-empty CLOSED replica, 
the container should be moved back to
+       * CLOSED state.
+       *
+       * HDDS-12421: If a DELETED container has a non-empty CLOSED replica, 
the container should also be moved back to
+       * CLOSED state.
        */
+
+      boolean replicaIsEmpty = replica.hasIsEmpty() && replica.getIsEmpty();
+      // If container is in DELETED state and the reported replica is empty, 
delete the empty replica.
+      if (container.getState() == HddsProtos.LifeCycleState.DELETED && 
replicaIsEmpty) {
+        deleteReplica(containerId, datanode, publisher, "DELETED");

Review Comment:
   The `deleteReplica` method currently sends a force delete command. If it's 
an empty container, force delete should be fine... but seeing how bugs can 
creep up in the delete path, to be super sure, should we send a non-force 
delete?
   
   A non-force delete means the replica will get deleted if it's not in OPEN 
state and if the DB says the replica doesn't have any blocks.



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerManagerImpl.java:
##########
@@ -178,13 +201,13 @@ void 
testTransitionDeletingToClosedStateAllowsOnlyDeletingContainers() throws IO
             ReplicationFactor.THREE), "admin");
     final ContainerID cid = container.containerID();
     assertEquals(LifeCycleState.OPEN, 
containerManager.getContainer(cid).getState());
-    assertThrows(IOException.class, () -> 
containerManager.transitionDeletingToClosedState(cid));
+    assertThrows(IOException.class, () -> 
containerManager.transitionDeletingOrDeletedToClosedState(cid));

Review Comment:
   Should change the name of this test method since it now allows DELETED -> 
CLOSED as well, and assert that it allows that.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to