Repository navigation
Add setting s3_request_payer for requester-pays S3 buckets - #131512
Conversation
A requester-pays bucket refuses every request without a signed `x-amz-request-payer: requester` header. The only way to send it was the `headers()` argument of the `s3` table function, so `ENGINE = S3`, S3 disks and `BACKUP`/`RESTORE` could not read such a bucket. Add a client field `request_payer` to `S3AuthSettings`. Through the existing lookup it is the query setting `s3_request_payer`, the `request_payer` key of the `<s3>` section and of an endpoint section, and the key of an S3 disk; an endpoint or disk key takes precedence over the query setting. `requester` is the only accepted value, anything else is `BAD_ARGUMENTS`. `getClient` and `makeS3Client` append the derived header to the client's extra headers, which are signed into every request kind, the same path the `headers()` argument uses. In `getClient` it is added after the metadata-load clear of the configured headers: that clear runs on every restricted metadata load, also for a table whose client keeps its explicit keys, and such a client is never rebuilt, so a header added before it was lost by a persistent `S3` table after a restart. It is still checked by the existing final `<http_forbid_headers>` check. `makeS3Client` never filters its header list, so it checks the derived header explicitly and appends it after the restriction clears the server-config headers. The field is a scalar, not request-auth material, so `clearServerManagedRequestAuth` keeps it under the default `s3_allow_server_credentials_in_user_queries = 0`. The integration test puts a mock in front of MinIO that redirects a request to MinIO only when the header is present and signed, and answers 403 otherwise. It runs the endpoint and disk keys under a conflicting `s3_request_payer`, and re-reads the `S3` table and the disk table after a server restart. Related: ClickHouse#131473 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Internal second-model review (2 rounds; final round: 0 findings)
|
|
cc @jkartseva, could you review this? It adds the setting s3_request_payer and a request_payer endpoint/disk key (one new S3AuthSettings field) that put x-amz-request-payer: requester into the S3 client's signed extra headers in getClient and in makeS3Client for BACKUP/RESTORE, so requester-pays buckets work without a raw header. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261114-015302 |
|
Workflow [PR], commit [80b4857] Summary: ✅
AI ReviewSummaryAdds Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes72 object files changed (+46.70 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1211 translation units recompiled, 6592 s compile time in total, 1211 of them have a recent master baseline. |
…tting # Conflicts: # src/IO/S3AuthSettings.h
Both endpoint sections of `requester_pays.xml` (one with keys, one keyless) now also carry `Authorization: Bearer endpoint-header-token`. The new test checks that under the default `s3_allow_server_credentials_in_user_queries = 0` no request carries it next to `request_payer`: `s3()` writes and reads, `S3` tables before and after a server restart, a bare-URL `BACKUP`, and the redirected requests. The requester-pays mock now records every request (`GET /__requests`, `POST /__reset`) and routes an accepted request through a recorded `/__redirected` hop, which checks it again, before redirecting it to MinIO, so the redirected request is observed too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review of the master merge and the new test (2 rounds; final round: 1 nit)
|
Pre-PR validation gate, round 2: master merge + negative endpoint-header test (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261116-204800 |
The 26.11 release branch was cut without this PR and master is now 26.12, so the settings history check requires the record of the new setting under the current version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`s3_request_payer` and the `request_payer` key of an endpoint section or a disk are now the enum `S3RequestPayer` with the values `none` (default) and `requester`. An invalid value is rejected when the setting or the config key is set, instead of when the S3 client is created. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tting # Conflicts: # src/IO/S3AuthSettings.h
AI review of a later commit does not approve the PR, see the AI Review comment.
`copyS3File` checked the copied object (`s3_check_objects_after_upload`)
through the source client. When the native copy is refused, the fallback
uploads the object through the destination client and checks it there, and
the outer check then repeated it through the source client. A `RESTORE`
from a backup that is not requester-pays into a disk with `request_payer`
on the same endpoint therefore failed after the upload succeeded: the
source client's `HeadObject` carries no `x-amz-request-payer`, and the
destination answers 403 ("Immediately after upload: Object ... suddenly
disappeared"). The same happens whenever the destination accepts only its
own client, e.g. other credentials.
Check through the destination client, which owns the destination in every
caller (it equals the source client unless a caller passes another one).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
711cfda
Related: #131473
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add the setting
s3_request_payerand therequest_payerkey of an endpoint section of the<s3>configuration and of an S3 disk. Set it torequesterto read and write requester-pays S3 buckets with thes3table function, theS3table engine, S3 disks andBACKUP/RESTORE, without passing the rawx-amz-request-payerheader.Description
A requester-pays S3 bucket refuses every request that does not carry
x-amz-request-payer: requester. Today it can be sent only as a raw header: theheaders()argument ofs3/S3, or aheaderkey of a disk or an endpoint section, and an endpointheaderis dropped for user queries under the defaults3_allow_server_credentials_in_user_queries = 0. There is no setting, andBACKUP/RESTOREwith keys in the query cannot send it at all (#131473).This adds the setting
s3_request_payerand therequest_payerkey of an<s3>endpoint section and of an S3 disk. One newS3AuthSettingsfield of the enum typeS3RequestPayer(noneorrequester) serves all three, so an endpoint or disk key takes precedence over the setting.getClient(table functions, engines, disks) andmakeS3Client(BACKUP/RESTORE) add the header to the client's signed extra headers after their header clears, so persistentS3tables keep it across restarts.copyS3Filenow checks a copied object (s3_check_objects_after_upload) through the destination client: a requester-pays destination refuses a source client without the header.This also answers item 2 of #131473: a generic endpoint
headerstays dropped under the restriction, since it can carry a credential such asAuthorizationthat would also follow a redirect;request_payeris not one.Validation: a
test_storage_s3mock in front of MinIO refuses (403) every request without a signedx-amz-request-payer: requesteroutsideowner_pays/and redirects the rest through itself.test_request_payercovers writes,HeadObject,ListObjectsV2, the endpoint key, the disk key, both keys unders3_request_payer = 'none', a restart,BACKUP/RESTORE, aRESTOREinto the disk withs3_check_objects_after_upload,none, an invalid value and<http_forbid_headers>; each case fails on master.test_request_payer_does_not_send_endpoint_headerschecks that anAuthorizationheader next torequest_payerin keyed and keyless endpoint sections reaches no request:s3,S3tables across a restart, a bare-URLBACKUP, redirects. Its keyless cases fail without #131104.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131512]
Version info
26.12.1.143-master(included in26.12and later)