smengcl opened a new pull request, #11680: URL: https://github.com/apache/ozone/pull/11680
Generated-by: Claude Code (Opus 5.5) ## What changes were proposed in this pull request? `OMBucketSetPropertyRequest` and `OMBucketSetOwnerRequest` parse the bucket's default replication config (`OmBucketArgs.getFromProtobuf`) in `validateAndUpdateCache`, outside the request's error handling. An unknown EC codec, or replication type EC without an EC config, fails there with an `IllegalArgumentException` or `UnsupportedOperationException` instead of an `OMException` with a result code. The same happens for a multipart `CreateKey` (its `preExecute` resolves the replication config only for non-multipart keys) and for `CreateDirectory` in OBS and LEGACY buckets. This PR adds `OzoneConfigUtil.toReplicationConfig` and `OzoneConfigUtil.toDefaultReplicationConfig`, which throw `OMException` with `INVALID_REQUEST` for an invalid replication config, and: - parses the default replication config in `preExecute` of `OMBucketSetPropertyRequest`, so an invalid one is rejected before the request is replicated; - parses `OmBucketArgs` inside the `try` block of `validateAndUpdateCache` in `OMBucketSetPropertyRequest` and `OMBucketSetOwnerRequest`; - uses `toDefaultReplicationConfig` in `OMBucketCreateRequest.preExecute`, which already parsed and validated it, so it also returns `INVALID_REQUEST` there; - uses `toReplicationConfig` in `OzoneConfigUtil.resolveReplicationConfigPreference` (key, file and multipart upload requests) and in `OMKeyRequest.dirKeyInfoBuilderNoACL` (directory key info). The Ozone client only sends known codecs, so it sees no difference. No protocol, version or layout change. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-17299 ## How was this patch tested? - New `testRejectInvalidReplicationConfig`: - `TestOMBucketSetPropertyRequest`: an unknown EC codec and EC without an EC config, `preExecute` of the set property request fails with `INVALID_REQUEST`, and `validateAndUpdateCache` of both the set property and the set owner request returns `INVALID_REQUEST`. - `TestOMKeyCreateRequest` (and so `TestOMKeyCreateRequestWithFSO`): multipart key with an unknown EC codec, `validateAndUpdateCache` returns `INVALID_REQUEST`. - `TestOMDirectoryCreateRequest`: directory with an unknown EC codec, `validateAndUpdateCache` returns `INVALID_REQUEST`. Each fails without the change. - The related OM request test classes pass locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
