Skip to content

Cherry pick #124453 to 26.9: Add S3 bucket to remote_url_allow_hosts - #124847

Merged
robot-ch-test-poll2 merged 10 commits into
backport/26.9/124453from
cherrypick/26.9/124453
Oct 14, 2026
Merged

robot-ch-test-poll2 merged 10 commits into
backport/26.9/124453from
cherrypick/26.9/124453

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

scanhex12 and others added 9 commits October 7, 2026 15:49
`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`
@robot-clickhouse robot-clickhouse added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Oct 9, 2026
@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Dear @jkartseva, @scanhex12, this cherry-pick PR has not been updated for 3d0h6m48s. 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.9/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]>
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit db76d37 into backport/26.9/124453 Oct 14, 2026
1 check passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.9/124453 branch October 14, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants