Repository navigation
Cherry pick #124453 to 26.7: Add S3 bucket to remote_url_allow_hosts - #124845
Merged
robot-ch-test-poll2 merged 10 commits intoOct 14, 2026
Merged
Conversation
`RemoteHostFilter` only matches the host of a URL, so on a shared path-style endpoint such as `s3.us-west-2.amazonaws.com` it can either allow every bucket in the region or none. After #123114 made `BACKUP`/`RESTORE` to `S3` honor the filter, Cloud instances with `remote_url_allow_hosts` could no longer reach the platform backup bucket, and allowing the whole host would defeat the setting. Add an `s3_bucket` entry of the form `host/bucket` or `host:port/bucket`. S3 URLs are checked through `S3::URI::checkRemoteHostFilter`, which accepts the URL when the parsed endpoint host and bucket are listed, and otherwise falls back to the host check. The bucket comes from the parser, so the entry matches both path-style and virtual-hosted-style URLs. Used by the `s3` table functions and engines, the `S3` database engine, `BACKUP`/`RESTORE` to `S3` and the redirect check in `S3::Client`. Related: #123114 Related: ClickHouse/clickhouse-private#78644 Co-Authored-By: Claude Fable 5.1 <[email protected]>
`DatabaseS3::isTableExist` and `getTableImpl` go through `S3::URI::checkRemoteHostFilter` as well; check that a table in the allowed bucket is visible and readable while the same path in another bucket on the same endpoint is not. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`RemoteHostFilter::setValuesFromConfig` cleared the allow lists and refilled them in place, so a malformed `<s3_bucket>` left only the entries preceding it while the filter stayed initialized. Parse into local containers and swap them in together with `is_initialized` only on success. Also document that `307 Temporary Redirect` locations are checked only against `<host>` and `<host_regexp>`, not `<s3_bucket>`. #124453 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Integration test `test_remote_host_filter_s3_bucket`: - a second node with `<s3_bucket>minio1/root</s3_bucket>` checks the entry form without a port, which is the form for a cloud endpoint on port 443 - the `base_backup` of an incremental backup goes through the same check - `SYSTEM RELOAD CONFIG` applies a new list without a restart, and a malformed entry placed first makes the reload fail and keeps the previous list - the positive cases of the custom disk test use `query`, because `query_and_get_error` raises when the query succeeds - a comment explains why the `S3` database test expects `UNKNOWN_TABLE` Unit tests: - `gtest_remote_host_filter`: entry format validation, port semantics of `isBucketAllowed`, absent section versus present but empty section - `gtest_s3_uri`: `checkRemoteHostFilter` for the path-style and the virtual-hosted form of one bucket, another bucket, another port, and the fallback to a `<host>` entry Docs and `config.xml`: a 301 redirect returned by S3 is checked against the bucket entries, a 307 redirect is checked by host only. Verified with the CI `build_amd_binary` of 7412e40: 10 of 12 tests pass; the two custom disk cases need the disk check that 45f7386 adds. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`DiskFromAST::createCustomDisk` walked the disk AST with `InDepthNodeVisitor`, which appends `While processing <ast>` to any exception. The `disk` function is masked only as a setting value (`FieldFromASTImpl`), so the bare `ASTFunction` was printed with its credentials. Any failure while creating a custom disk, such as the new `UNACCEPTABLE_URL` check for S3 disks, put `secret_access_key` into the error and the server log, and the test masking rule turned that into an abort. Use a plain bottom-up traversal that does not decorate exceptions. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124453&sha=7fb25dfd064ffe3ade1142182e171aba3f875e92&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20flaky%29 #124453 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-prefix Add S3 bucket to `remote_url_allow_hosts`
Contributor
|
Dear @jkartseva, @scanhex12, this cherry-pick PR has not been updated for 3d0h7m55s. Please resolve the conflicts to backport #124453, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity. |
…ypick/26.7/124453 Adapted to the pre-#110665 `ObjectStorageFactory::create` signature of this release branch: `run_remote_host_filter_check` is appended after the existing `skip_access_check` parameter, and `registerDiskObjectStorage` names its `custom_disk` argument to derive it. The `url.checkRemoteHostFilter` call in `StorageS3Configuration::check` keeps this branch's `checkAndNormalizeHeaders`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #124453
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job