devmadhuu opened a new pull request, #12232:
URL: https://github.com/apache/ozone/pull/12232
## What changes were proposed in this pull request?
Since HDDS-10979, any valid `x-amz-storage-class` header overrides the
bucket's settings. Many S3 tools send
`STANDARD` by default, so an object written to an EC bucket becomes
RATIS/THREE. With storage policy support
(HDDS-17727), a header such as `GLACIER` can also move data to COLD in a
WARM bucket. Admins have no way to make
the bucket settings win.
This PR adds an S3 Gateway setting,
`ozone.s3g.storage-class.client-override`, with three modes:
| Mode | Rule |
|---|---|
| `allow` (default) | The header decides replication and storage policy.
Same as today. |
| `ignore` | The header is validated, then the write is resolved as if
neither it nor the `storage-config` header was sent. |
| `reject` | The write fails with `400 InvalidStorageClass` if the header
asks for anything other than what the write would get without it. |
**Example 1: only the storage policy differs.** Bucket: RATIS/THREE, policy
WARM. Request: PUT with
`x-amz-storage-class: GLACIER` (RATIS/THREE + COLD).
| Mode | Result |
|---|---|
| `allow` | Stored as COLD. |
| `ignore` | Stored as WARM. The upload succeeds. |
| `reject` | `400 InvalidStorageClass`: "Storage class GLACIER requests
storage policy COLD, but the bucket uses storage policy WARM. ..." |
**Example 2: only replication differs.** Bucket: EC rs-6-3, policy WARM.
Request: PUT with
`x-amz-storage-class: STANDARD` (RATIS/THREE, no policy of its own).
| Mode | Result |
|---|---|
| `allow` | Stored as RATIS/THREE. |
| `ignore` | Stored as EC rs-6-3. The upload succeeds. |
| `reject` | `400 InvalidStorageClass`: "Storage class STANDARD requests
replication RATIS/THREE, but the bucket uses replication EC{rs-6-3-1024k}. ..."
|
**Details**
- "Without the header" means today's no-header rule. Replication comes from
the gateway's `ozone.replication`
if set, otherwise the bucket's replication, otherwise OM's default. No
storage policy is sent, so OM applies the
bucket's policy or its own default.
- Without a header, every mode behaves exactly as today. A header that
matches what the bucket already gives is
accepted in every mode. For example, `STANDARD_IA` on an EC bucket uses
the bucket's EC layout and sets no
policy.
- In `reject` mode:
- Replication is compared only when the gateway or the bucket sets one,
because S3 Gateway cannot know OM's
server default.
- A class that sets a storage policy is rejected on a bucket that has no
storage policy. OM assigns a policy
to new buckets, so this applies only to buckets created before storage
policy support.
- An unknown storage class or an invalid `storage-config` layout is rejected
in every mode.
- The setting applies to PutObject, conditional PutObject, CopyObject and
CreateMultipartUpload. Part uploads
are not affected: they take replication and storage policy from their
multipart upload, so a part that repeats
the initiate's header does not fail in `reject` mode.
- The mode is read once when S3 Gateway starts, like the other storage class
settings. An invalid value prevents
startup.
**Code changes**
- `S3GatewayConfigKeys` and `ozone-default.xml`: the new key, with default
`allow`.
- `S3StorageClassResolver`:
- New `ClientOverride` enum, read in the constructor.
- New `resolve(...)` method that returns replication and storage policy
with the mode applied.
- `ResolvedStorageClass`: moved from a nested class in `EndpointBase` to
`org.apache.hadoop.ozone.s3.util`, so
the resolver can return it.
- `EndpointBase`:
- `resolveStorageClass` delegates to `S3StorageClassResolver.resolve`.
- `getReplicationConfig` is now used only by part uploads to choose the
write path. It keeps the existing
replication rules without the mode.
**Not in this PR**
- User docs for the setting belong on ozone-site (HDDS-17545).
- The OM-level "enforce bucket replication" bucket attribute proposed in
HDDS-17303 is separate work.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-17521
## How was this patch tested?
- New unit tests:
- `TestS3StorageClass`:
- `allow` is the default;
- without a header every mode gives the same result;
- an unknown class or an invalid EC layout is rejected in every mode;
- `ignore` drops the class and the `storage-config` header but keeps the
gateway's `ozone.replication`;
- `reject` accepts a matching header and rejects:
- a different replication;
- a different storage policy;
- a storage policy on a bucket without one;
- a configured STANDARD policy that differs from the bucket's;
- mode values are case-insensitive, and an unknown value fails
construction.
- `TestObjectPut`: `ignore` and `reject` for PutObject and CopyObject on
an EC rs-6-3, WARM bucket.
- `TestInitiateMultipartUpload`: `ignore` and `reject` for
CreateMultipartUpload; a part upload that sends the
header still succeeds in `reject` mode.
- `ozone-s3gateway` unit tests pass: 2113 tests.
- `TestOzoneConfigurationFields` passes with the new key in
`ozone-default.xml`.
- Checkstyle passes for `ozone-s3gateway` and `hdds-common`.
--
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]