feat(clp-package): Parameterize clp-package Docker image by Ubuntu codename; auto-detect host version.#2273
feat(clp-package): Parameterize clp-package Docker image by Ubuntu codename; auto-detect host version.#2273junhaoliao wants to merge 4 commits into
Conversation
…me; auto-detect host version.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughDocker build is parameterized by UBUNTU_VERSION_CODENAME; Dockerfile now removes any existing account with the requested UID before creating the runtime user. The build script detects the host Ubuntu codename and passes it as a build-arg, and the GitHub Action/workflow expose and forward the same codename. ChangesDocker Build Parameterization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| USER="clp-user" | ||
|
|
||
| RUN useradd --uid ${UID} --shell /bin/bash --home-dir ${CLP_HOME} ${USER} | ||
| RUN userdel -r ubuntu 2>/dev/null || true \ |
There was a problem hiding this comment.
Instead of hardcoding ubuntu, we should resolve the username from the UID, using something like getent passwd "${UID}" | cut -d: -f1.
Also, is it possible to raise an error when encountering a UID conflict?
There was a problem hiding this comment.
sg. i tried to address it in 5af1885 . let me know if i understand correctly
|
|
||
| ubuntu_version_codename="jammy" | ||
| if [[ -f /etc/os-release ]]; then | ||
| host_codename="$(. /etc/os-release && echo "$VERSION_CODENAME")" |
There was a problem hiding this comment.
Right now, task package builds a clp-package image using the same Ubuntu release as the host invoking the task command. However, I believe a 22.04 host should still be able to build a 24.04 clp-package image.
Should we expose the Ubuntu version codename as a Task argument or environment variable so the package target is not tied to the host release?
There was a problem hiding this comment.
dynamic ubuntu version detection on host should make more sense. the main reason why we want to avoid hardcoding a version of the ubuntu image is because whatever (Python wheels, glibc dependent binaries, etc.) a non-Jammy host builds do not run inside the Jammy-based image container.
the long-term plan is to migrate the base image from Ubuntu to Muslinux / Manylinux as @jackluo923 proposed. we (or whoever has bandwidth) can work on it in the next month. also, i think we shall explore setting up https://containers.dev/ too.
for now, this PR can unblock our developers to develop on different versions of Ubuntu hosts, without use of Ubuntu Jammy build containers
let me know what you think
There was a problem hiding this comment.
just realized that tools/docker-images/clp-package/Dockerfile copies built artifacts instead of building the package itself. Yes I agree we should keep host and host-built container image consistent.
Bill-hbrhbr
left a comment
There was a problem hiding this comment.
Need to update docs:
| default: "amd64" | ||
| required: false |
There was a problem hiding this comment.
| default: "amd64" | |
| required: false | |
| required: true |
Maybe open an issue to make this required?
|
|
||
| ubuntu_version_codename="jammy" | ||
| if [[ -f /etc/os-release ]]; then | ||
| host_codename="$(. /etc/os-release && echo "$VERSION_CODENAME")" |
There was a problem hiding this comment.
just realized that tools/docker-images/clp-package/Dockerfile copies built artifacts instead of building the package itself. Yes I agree we should keep host and host-built container image consistent.
| RUN existing_user="$(getent passwd "${UID}" | cut --delimiter=: --fields=1)" || true; \ | ||
| [ -z "${existing_user}" ] || userdel --remove "${existing_user}" \ | ||
| || { echo "ERROR: Cannot delete user '${existing_user}' that occupies UID ${UID}"; exit 1; } | ||
| RUN useradd --uid ${UID} --shell /bin/bash --home-dir ${CLP_HOME} ${USER} |
There was a problem hiding this comment.
To make the user handling more coherent, we can maybe merge these two inside a single RUN. Your choice.
Description
Previously, the
clp-packageDocker image was hardcoded toubuntu:jammy. Binaries built on an Ubuntu 24.04 (Noble) host (glibc 2.39) cannot run inside a Jammy container (glibc 2.35), causingtaskto fail on Noble hosts at the package-image stage. This affects both the C++ binaries (which require GLIBC_2.38) and Python packages with native extensions (e.g.,_mysql_connector.so,psutil,greenlet) that are compiled on the host and linked against its glibc.This PR makes two changes to
tools/docker-images/clp-package/:Dockerfile — The base image is now parameterized via
ARG UBUNTU_VERSION_CODENAME=jammysoFROM ubuntu:${UBUNTU_VERSION_CODENAME}resolves to the host-matching Ubuntu version. Additionally,userdel -r ubuntuis called beforeuseradd clp-userto handle the defaultubuntuuser present in Noble cloud images (UID 1000), which would otherwise conflict with theclp-userUID.build.sh — Auto-detects the host's Ubuntu codename from
/etc/os-release(VERSION_CODENAME) and passes it as--build-arg UBUNTU_VERSION_CODENAME=<codename>. Defaults tojammywhen detection fails, preserving backward compatibility.Checklist
breaking change.
Validation performed
Scenario 1: Full build on Noble host
Task
Run
taskon an Ubuntu 24.04 (Noble) host to verify the build succeeds end-to-end.Command
Output
Explanation
The Docker image build resolved the base image to
ubuntu:noble, and the fulltaskpipeline completed successfully on a Noble host.Scenario 2: build.sh auto-detects the host Ubuntu codename
Task
Verify that
build.shreads the host's codename from/etc/os-releaseand passes it as a build-arg.Command
Output
Explanation
The script defaults to
jammybut correctly overrides with the host'sVERSION_CODENAME=noble, ensuring the runtime image's glibc matches the host.Scenario 3: Package Dockerfile builds with UBUNTU_VERSION_CODENAME=noble
Task
Verify the Dockerfile accepts
--build-arg UBUNTU_VERSION_CODENAME=nobleand pullsubuntu:nobleas the base image.Command
Output
Explanation
Docker resolved the base image to
docker.io/library/ubuntu:noble, confirming the build-arg is correctly substituted into theFROMdirective.Scenario 4: Package Dockerfile syntax check with default (jammy)
Task
Verify backward compatibility — the Dockerfile still works with the default
jammycodename.Command
Output
Explanation
The Dockerfile passes syntax validation with the default
jammyvalue, confirming no breaking change for existing builds.Scenario 5: Container runs Noble and has correct user setup
Task
Verify the built container is based on Ubuntu Noble and the
ubuntuuser is removed whileclp-userexists with UID 1000.Command
Output
Explanation
The container runs Ubuntu Noble; the default
ubuntuuser (present in Noble cloud images, UID 1000) was removed, andclp-userwas created with UID 1000, avoiding the UID conflict that would otherwise occur.Scenario 6: Start CLP package on Noble host
Task
Verify
start-clp.shstarts all CLP services successfully.Command
Output
Explanation
All services (database, queue, redis, results-cache, compression worker/scheduler, query worker/scheduler, api-server, webui, reducer, garbage-collector) started and became healthy.
Scenario 7: Compress logs
Task
Verify log compression works end-to-end in the Noble-based package.
Command
Output
Explanation
Compression completed successfully with a 38.70x compression ratio, confirming that the Noble-based runtime image correctly executes the CLP binaries built on the Noble host.
Scenario 8: Search logs
Task
Verify log search works end-to-end in the Noble-based package.
Command
Output
Explanation
Search completed successfully, confirming the query pipeline works correctly with the Noble-based package.
Summary by CodeRabbit