This is an automated email from the ASF dual-hosted git repository.
tejaskriya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new dc1882de6f8 HDDS-13534. Check container state with the good states
instead of the bad one (#8929)
dc1882de6f8 is described below
commit dc1882de6f8a6b4642bddbd707bf1904e60e6291
Author: Gargi Jaiswal <[email protected]>
AuthorDate: Mon Aug 18 14:13:33 2025 +0530
HDDS-13534. Check container state with the good states instead of the bad
one (#8929)
---
.../debug/replicas/ContainerStateVerifier.java | 27 +++++++++++++++++-----
.../ozone/debug/replicas/ReplicasVerify.java | 7 +++---
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ContainerStateVerifier.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ContainerStateVerifier.java
index fef3030fd15..465f1e99c94 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ContainerStateVerifier.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ContainerStateVerifier.java
@@ -20,7 +20,9 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.io.IOException;
+import java.util.EnumSet;
import java.util.Objects;
+import java.util.Set;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto;
@@ -36,7 +38,7 @@
/**
* Verifies the state of a replica from the DN.
- * [DELETED, UNHEALTHY, INVALID] are considered bad states.
+ * [OPEN, CLOSING, QUASI_CLOSED, CLOSED] are considered good states.
*/
public class ContainerStateVerifier implements ReplicaVerifier {
private static final String CHECK_TYPE = "containerState";
@@ -46,6 +48,22 @@ public class ContainerStateVerifier implements
ReplicaVerifier {
// cache for container info and encodedToken from the SCM
private final Cache<Long, ContainerInfoToken> encodedTokenCache;
+ private static final Set<ContainerDataProto.State> GOOD_REPLICA_STATES =
+ EnumSet.of(
+ ContainerDataProto.State.OPEN,
+ ContainerDataProto.State.CLOSING,
+ ContainerDataProto.State.QUASI_CLOSED,
+ ContainerDataProto.State.CLOSED
+ );
+
+ private static final Set<HddsProtos.LifeCycleState> GOOD_CONTAINER_STATES =
+ EnumSet.of(
+ HddsProtos.LifeCycleState.OPEN,
+ HddsProtos.LifeCycleState.CLOSING,
+ HddsProtos.LifeCycleState.QUASI_CLOSED,
+ HddsProtos.LifeCycleState.CLOSED
+ );
+
public ContainerStateVerifier(OzoneConfiguration conf, long
containerCacheSize) throws IOException {
containerOperationClient = new ContainerOperationClient(conf);
xceiverClientManager = containerOperationClient.getXceiverClientManager();
@@ -99,11 +117,8 @@ public BlockVerificationResult verifyBlock(DatanodeDetails
datanode, OmKeyLocati
private boolean areContainerAndReplicasInGoodState(ContainerDataProto.State
replicaState,
HddsProtos.LifeCycleState containerState) {
- return (replicaState != ContainerDataProto.State.UNHEALTHY &&
- replicaState != ContainerDataProto.State.INVALID &&
- replicaState != ContainerDataProto.State.DELETED &&
- containerState != HddsProtos.LifeCycleState.DELETING &&
- containerState != HddsProtos.LifeCycleState.DELETED);
+ return GOOD_REPLICA_STATES.contains(replicaState) &&
+ GOOD_CONTAINER_STATES.contains(containerState);
}
private ContainerDataProto fetchContainerDataFromDatanode(DatanodeDetails
dn, long containerId,
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
index e4222ae3936..f655a47f548 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
@@ -229,9 +229,10 @@ static class Verification {
private boolean doExecuteBlockExistence;
@CommandLine.Option(names = "--container-state",
- description = "Check the container and replica states. " +
- "Containers in [DELETING, DELETED] states, or " +
- "it's replicas in [DELETED, UNHEALTHY, INVALID] states fail the
check.",
+ description = "Check the container and replica states." +
+ " Containers must be in [OPEN, CLOSING, QUASI_CLOSED, CLOSED]
states," +
+ " and it's replicas must be in [OPEN, CLOSING, QUASI_CLOSED,
CLOSED] states" +
+ " to pass the check. Any other states will fail the verification.",
defaultValue = "false")
private boolean doExecuteReplicaState;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]