From a2e1516e84add6ebe644c65ee0afe266c8a1a7dc Mon Sep 17 00:00:00 2001 From: Jimmy Weng Date: Mon, 28 Apr 2025 12:22:33 +0800 Subject: [PATCH 1/3] HDDS-12877. Return StorageClass in HeadObject and add smoketest verification --- .../dist/src/main/smoketest/s3/objecthead.robot | 10 ++++++++++ .../hadoop/ozone/s3/endpoint/ObjectEndpoint.java | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot index 66f3461b01dd..5ccebafc85b3 100644 --- a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot +++ b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot @@ -60,3 +60,13 @@ Head non existing key ${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/non-existent 255 Should contain ${result} 404 Should contain ${result} Not Found + + +HeadObject Should Return StorageClass + Execute echo "Randomtext" > /tmp/testfile + ${put_result} = Execute AWSS3APICli and checkrc put-object --bucket ${BUCKET} --key ${PREFIX}/object-exist --body /tmp/testfile 0 + + ${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/object-exist 0 + Should Contain ${result} "StorageClass": "STANDARD" + + ${result} = Execute AWSS3APICli and checkrc delete-object --bucket ${BUCKET} --key ${PREFIX}/object-exist 0 diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java index 21718295b9c1..cd634f9aef9f 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java @@ -646,7 +646,8 @@ public Response head( ResponseBuilder response = Response.ok().status(HttpStatus.SC_OK) .header("Content-Length", key.getDataSize()) - .header("Content-Type", "binary/octet-stream"); + .header("Content-Type", "binary/octet-stream") + .header("x-amz-storage-class", "STANDARD"); String eTag = key.getMetadata().get(ETAG); if (eTag != null) { From a74320eb93fcb7f19fec53aa16aa2026769c3abd Mon Sep 17 00:00:00 2001 From: Jimmy Weng Date: Thu, 1 May 2025 18:23:48 +0800 Subject: [PATCH 2/3] HDDS-12877. Avoid hard-coded STORAGE_CLASS_HEADER value --- .../org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java index cd634f9aef9f..17a6f6c06639 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java @@ -644,10 +644,14 @@ public Response head( throw ex; } + S3StorageType s3StorageType = key.getReplicationConfig() == null ? + S3StorageType.STANDARD : + S3StorageType.fromReplicationConfig(key.getReplicationConfig()); + ResponseBuilder response = Response.ok().status(HttpStatus.SC_OK) .header("Content-Length", key.getDataSize()) .header("Content-Type", "binary/octet-stream") - .header("x-amz-storage-class", "STANDARD"); + .header(STORAGE_CLASS_HEADER, s3StorageType.toString()); String eTag = key.getMetadata().get(ETAG); if (eTag != null) { From 0b308e72905efb911c80f396913a8f3e3b81d6d2 Mon Sep 17 00:00:00 2001 From: Jimmy Weng Date: Thu, 1 May 2025 18:24:44 +0800 Subject: [PATCH 3/3] HDDS-12877. Integrate StorageClass header check into existing test --- .../dist/src/main/smoketest/s3/objecthead.robot | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot index 5ccebafc85b3..88bbb55a360e 100644 --- a/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot +++ b/hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot @@ -34,6 +34,7 @@ Head existing object ${result} = Execute AWSS3APICli and checkrc put-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 --body /tmp/testfile 0 ${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 0 + Should Contain ${result} "StorageClass": ${result} = Execute AWSS3APICli and checkrc delete-object --bucket ${BUCKET} --key ${PREFIX}/headobject/key=value/f1 0 Head object in non existing bucket @@ -60,13 +61,3 @@ Head non existing key ${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/non-existent 255 Should contain ${result} 404 Should contain ${result} Not Found - - -HeadObject Should Return StorageClass - Execute echo "Randomtext" > /tmp/testfile - ${put_result} = Execute AWSS3APICli and checkrc put-object --bucket ${BUCKET} --key ${PREFIX}/object-exist --body /tmp/testfile 0 - - ${result} = Execute AWSS3APICli and checkrc head-object --bucket ${BUCKET} --key ${PREFIX}/object-exist 0 - Should Contain ${result} "StorageClass": "STANDARD" - - ${result} = Execute AWSS3APICli and checkrc delete-object --bucket ${BUCKET} --key ${PREFIX}/object-exist 0