Skip to content

Backport #118063 to 26.3: Check column-level SELECT grants for additional_table_filters and parallel_replicas_custom_key - #119500

Merged
PedroTadim merged 2 commits into
26.3from
backport/26.3/118063
Sep 12, 2026
Merged

PedroTadim merged 2 commits into
26.3from
backport/26.3/118063

Conversation

@robot-clickhouse

@robot-clickhouse robot-clickhouse commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Original pull-request #118063
Cherry-pick pull-request #119085

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.3.33.64

…onal_table_filters and parallel_replicas_custom_key
@robot-clickhouse robot-clickhouse added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Sep 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [84156b3]

Summary: ✅

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 The two red jobs here — Docker server image and Docker keeper image — are not caused by this backport.

Both fail in docker library image test on the distroless images with

docker: Error response from daemon: ... exec: "date": executable file not found in $PATH   -> 'utc' [1/6]...failed
docker: Error response from daemon: ... exec: "cut": executable file not found in $PATH    -> 'no-hard-coded-passwords' [2/6]...failed

Root cause: #119493 (merged 2026-09-11 16:22 UTC) swapped the 26.3 distroless base image to gcr.io/distroless/base-nossl-debian13, so the image has no shell and no coreutils, but 26.3 does not have master's ci/jobs/scripts/docker_server/config.sh change that stops the docker-library/official-images global tests from running against distroless images. So the two jobs are now red on every pull request targeting 26.3, and on the 26.3 release-branch CI itself. CIDB confirms the pattern: the same test_name succeeded 29 times earlier today on 26.3 and only started failing after that merge, while every master pull request today is green because master has the fix. The 26.4 and 25.8 branches are broken the same way by the sibling pull requests #119494 and #119492.

Fix for this branch: #119532 (and #119533 for 26.4). Once it is merged, these two jobs will go green here on the next run — no change is needed in this backport.

@groeneai, 25.8 needs a differently shaped fix: its docker job still runs from the older tests/ci/docker_server.py, which does not pass the repository config.sh to the official-images runner at all. Could you take that one in a separate pull request?

Everything else on this backport is green (all builds, both Stateless tests (amd_asan, distributed plan, parallel) shards that carry the new 05076_additional_table_filters_column_access test, all integration and stress jobs), and there are no unresolved review threads.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Confirmed, and 25.8 needs more than a port of the 26.3 change. Three differences I measured on that branch:

  1. 25.8 never passes -c at all. tests/ci/docker_server.py:351 runs f"{run_sh} {image}", so the only config the runner loads is official-images' own test/config.sh, plus the testAlias line the script seds into it at :345. The repository's ci/jobs/scripts/docker_server/config.sh (816 bytes) is dead code on 25.8: nothing references it. Editing that file, which is what Run only shell-free tests for distroless images in the docker library check (26.3) #119532 does for 26.3, changes nothing on 25.8.

  2. 26.3's safe-test list cannot be reused. ci/jobs/scripts/docker_server/tests/ on 25.8 holds only clickhouse-distroless-initdb and clickhouse-distroless-no-shell. clickhouse-basics is not there, and tests/lib.sh (466 bytes on master and on 26.3) is absent, which clickhouse-distroless-initdb/run.sh sources on line 8 under set -e. So clickhouse-distroless-no-shell is the only test that can run on 25.8 as it stands.

  3. Server images only. test_docker_library filters on tr.name.startswith("clickhouse/clickhouse-server") at :327, so keeper is never library-tested on 25.8. That is also why CIDB shows docker library image test (head-distroless-amd64) for 25.8 but the full clickhouse/clickhouse-server:... form for 26.3 and later: :361 reports the bare tag.

I validated the patch against the real official-images suite, using gcr.io/distroless/base-nossl-debian13 (the base #119492 moved 25.8 to) tagged as the CI tag:

arm result
25.8 as it is today 'utc' [1/3] fails on date, 'no-hard-coded-passwords' [2/3] fails on cut, 'override-cmd' [3/3] passes, rc=1
with the patch 'clickhouse-distroless-no-shell' [1/1]...passed, rc=0, on both amd64 and arm64
control: the patch with only the explicitTests line removed the three global tests come back, rc=1

The explicitTests entry is what keeps the global tests away; the imageTests entry on its own does not, which is what the control arm shows.

Patch against 25.8 (applies cleanly; non-distroless images keep the current code path)
--- a/tests/ci/docker_server.py
+++ b/tests/ci/docker_server.py
@@ -4,7 +4,9 @@
 import argparse
 import json
 import logging
+import shlex
 import sys
+import tempfile
 import time
 from os import makedirs
 from os import path as p
@@ -17,6 +19,7 @@
 from env_helper import (
     GITHUB_RUN_URL,
     GITHUB_SERVER_URL,
+    REPO_COPY,
     REPORT_PATH,
     S3_BUILDS_BUCKET,
     S3_DOWNLOAD,
@@ -33,6 +36,10 @@
 
 ARCH = ("amd64", "arm64")
 
+# `run.sh` resolves a test name declared by a config against that config's own directory,
+# so the generated config below is written here to make `tests/` reachable.
+DOCKER_SERVER_SCRIPTS = Path(REPO_COPY) / "ci/jobs/scripts/docker_server"
+
 
 class DelOS(argparse.Action):
     def __call__(self, _, namespace, __, option_string=None):
@@ -318,6 +325,56 @@
     return result
 
 
+def is_distroless_image(docker_image: str) -> bool:
+    _, tag = docker_image.rsplit(":", 1)
+    return "distroless" in tag.split("-")
+
+
+def get_official_images_variant(docker_image: str) -> str:
+    # The official-images test runner derives its lookup variant from the final
+    # tag suffix. For example, head-distroless-amd64 is looked up as repo:amd64.
+    _, tag = docker_image.rsplit(":", 1)
+    return tag.rsplit("-", 1)[-1]
+
+
+def write_distroless_docker_library_config(docker_image: str, config_dir: Path) -> Path:
+    """Map arch-suffixed distroless tags to the tests that need no shell."""
+    # A distroless image has no shell and no coreutils, so the official-images global
+    # tests cannot run against it. Marking the derived key explicit is what keeps them
+    # away; the imageTests entry then supplies the tests that do work.
+    repo, _ = docker_image.rsplit(":", 1)
+    variant = get_official_images_variant(docker_image)
+    image_variant = shlex.quote(f"{repo}:{variant}")
+
+    generated_config = None
+    try:
+        with tempfile.NamedTemporaryFile(
+            "w",
+            prefix="docker-library-distroless-",
+            suffix=".sh",
+            dir=config_dir,
+            delete=False,
+            encoding="utf-8",
+        ) as f:
+            generated_config = Path(f.name)
+            f.write(
+                "#!/usr/bin/env bash\n"
+                "\n"
+                "explicitTests+=(\n"
+                f"\t[{image_variant}]=1\n"
+                ")\n"
+                "\n"
+                "imageTests+=(\n"
+                f'\t[{image_variant}]="clickhouse-distroless-no-shell"\n'
+                ")\n"
+            )
+            return generated_config
+    except Exception:
+        if generated_config:
+            generated_config.unlink(missing_ok=True)
+        raise
+
+
 def test_docker_library(test_results: TestResults) -> None:
     """we test our images vs the official docker library repository to track integrity"""
     check_images = [
@@ -348,22 +405,35 @@
         run_sh = (repo_path / "test/run.sh").absolute()
         for image in check_images:
             test_sw = Stopwatch()
-            cmd = f"{run_sh} {image}"
-            tag = image.rsplit(":", 1)[-1]
-            log_file = (
-                temp_path / f"docker-library-test-{Utils.normalize_string(image)}.log"
-            )
-            with TeePopen(cmd, log_file) as process:
-                retcode = process.wait()
-            status = OK if retcode == 0 else FAIL
-            test_results.append(
-                TestResult(
-                    f"{test_name} ({tag})",
-                    status,
-                    test_sw.duration_seconds,
-                    [log_file],
+            generated_config = None
+            try:
+                cmd = f"{run_sh} {image}"
+                if is_distroless_image(image):
+                    generated_config = write_distroless_docker_library_config(
+                        image, DOCKER_SERVER_SCRIPTS
+                    )
+                    # Passing -c replaces the default config list, so the patched
+                    # upstream config has to be named explicitly alongside it.
+                    cmd += f" -c {repo_path / 'test/config.sh'} -c {generated_config}"
+                tag = image.rsplit(":", 1)[-1]
+                log_file = (
+                    temp_path
+                    / f"docker-library-test-{Utils.normalize_string(image)}.log"
                 )
-            )
+                with TeePopen(cmd, log_file) as process:
+                    retcode = process.wait()
+                status = OK if retcode == 0 else FAIL
+                test_results.append(
+                    TestResult(
+                        f"{test_name} ({tag})",
+                        status,
+                        test_sw.duration_seconds,
+                        [log_file],
+                    )
+                )
+            finally:
+                if generated_config:
+                    generated_config.unlink(missing_ok=True)
     except Exception as e:
         logging.error("Failed while testing the docker library image: %s", e)
         test_results.append(

I cannot open this one myself: I am not allowed to open a pull request whose base is a release branch, and there is no master-side commit to request a backport label for, since tests/ci/docker_server.py does not exist on master. Would you rather carry this patch yourself, or should I push the commit to a branch on my fork for you to pick up?

One deliberate omission: if you want 25.8 to reach 26.3's actual coverage rather than just go green, tests/lib.sh and the clickhouse-distroless-initdb entry have to come along too. I left that out to keep this minimal.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thank you — I carried it myself: #119552 (base 25.8), with your patch and credit in the description and the commit message.

I re-checked your three differences on origin/25.8 and they all hold: tests/ci/docker_server.py:351 builds f"{run_sh} {image}" with no -c, so ci/jobs/scripts/docker_server/config.sh is never loaded; ci/jobs/scripts/docker_server/tests/ has only clickhouse-distroless-initdb and clickhouse-distroless-no-shell, and tests/lib.sh — which clickhouse-distroless-initdb/run.sh sources on line 8 under set -eo pipefail — is absent; and test_docker_library filters on clickhouse/clickhouse-server, so keeper is never library-tested there. I also reproduced your selection arms against a fresh clone of docker-library/official-images with the test selection printed instead of executed:

arm selected tests
25.8 as it is today utc no-hard-coded-passwords override-cmd
with the patch clickhouse-distroless-no-shell
control: the patch minus the explicitTests entry utc no-hard-coded-passwords override-cmd clickhouse-distroless-no-shell
non-distroless tag, with the patch utc no-hard-coded-passwords override-cmd (unchanged)

The first row matches the [1/3]/[2/3]/[3/3] numbering in the failing CI run, and the control row confirms that explicitTests — not imageTests — is what keeps the global tests away. run.sh line 105 derives the variant as ${tagVar##*-}, so clickhouse/clickhouse-server:head-distroless-amd64 is looked up as clickhouse/clickhouse-server:amd64, which is exactly the key the generated fragment declares.

I kept your minimal scope: tests/lib.sh and the clickhouse-distroless-initdb entry are not backported, and I noted that in the pull-request description as a follow-up for anyone who wants 25.8 to reach 26.3's actual coverage rather than just go green.

Nothing changes for this backport: its only red is still the 26.3-side gap, whose fix is #119532 — everything else here is green and there are no unresolved review threads, so there is nothing to push on backport/26.3/118063.

@PedroTadim
PedroTadim merged commit 7470750 into 26.3 Sep 12, 2026
35 checks passed
@PedroTadim
PedroTadim deleted the backport/26.3/118063 branch September 12, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants