This is an automated email from the ASF dual-hosted git repository.
smengcl 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 56188231787 Align Echo with other container commands in HddsUtils.
56188231787 is described below
commit 56188231787ebbe4366edee3e914f25d050bd21a
Author: Siyao Meng <[email protected]>
AuthorDate: Fri Oct 16 16:52:26 2026 -0700
Align Echo with other container commands in HddsUtils.
---
.../java/org/apache/hadoop/hdds/HddsUtils.java | 1 +
.../ozoneimpl/TestOzoneContainerWithTLS.java | 32 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
index e9079b8b8bb..b5f51baf339 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
@@ -648,6 +648,7 @@ public static boolean requireContainerToken(Type cmdType) {
case UpdateContainer:
case GetContainerChecksumInfo:
case ListBlock:
+ case Echo:
return true;
default:
return false;
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
index 1a50ad151f9..a2dfea9fddf 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
@@ -90,6 +90,7 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.ozone.test.GenericTestUtils.LogCapturer;
+import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -243,6 +244,37 @@ public void testGetContainerMerkleTree() throws
IOException {
}
}
+ @Test
+ public void testEchoRequiresContainerToken() throws IOException {
+ conf.setBoolean(HddsConfigKeys.HDDS_CONTAINER_TOKEN_ENABLED, true);
+ OzoneContainer container = createAndStartOzoneContainerInstance();
+ XceiverClientManager clientManager =
+ new XceiverClientManager(conf, conf.getObject(ScmClientConfig.class),
aClientTrustManager());
+ XceiverClientSpi client = null;
+ try {
+ client = clientManager.acquireClient(pipeline);
+ long containerId = createAndCloseContainer(client, true);
+ TokenHelper tokenHelper = new TokenHelper(new SecurityConfig(conf),
keyClient);
+ String containerToken =
encode(tokenHelper.getContainerToken(ContainerID.valueOf(containerId)));
+ assertNotNull(ContainerProtocolCalls.echo(client, containerToken,
containerId, ByteString.EMPTY, 1, 0, true));
+
+ // A token that can be decoded is not enough, it has to be valid for the
container.
+ String otherContainerToken =
encode(tokenHelper.getContainerToken(ContainerID.valueOf(containerId + 1)));
+ XceiverClientSpi finalClient = client;
+ StorageContainerException exception =
assertThrows(StorageContainerException.class, () ->
+ ContainerProtocolCalls.echo(finalClient, otherContainerToken,
containerId, ByteString.EMPTY, 1, 0, true));
+ assertEquals(ContainerProtos.Result.BLOCK_TOKEN_VERIFICATION_FAILED,
exception.getResult());
+ } finally {
+ if (container != null) {
+ container.stop();
+ }
+ if (client != null) {
+ clientManager.releaseClient(client, true);
+ }
+ IOUtils.closeQuietly(clientManager);
+ }
+ }
+
@Test
public void testLongLivingClientWithCertRenews() throws Exception {
LogCapturer logs = captureLogs(ClientTrustManager.class);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]