feat(cassandra): provision cqlsh in a Python virtualenv for Python 3.12+ hosts - #39
Merged
Conversation
…12+ hosts The cqlsh bundled with Cassandra (tarball and distro package) uses a Python driver that imports stdlib modules removed in Python 3.12 (asyncore, imp), so it aborts at startup on hosts whose system Python is >= 3.12 — Ubuntu 24.04+ and Debian 13 — on both tar and pkg installs. Add recipes/cqlsh_venv.rb: it builds an isolated venv with the maintained standalone cqlsh PyPI package and installs a /usr/local/bin/cqlsh wrapper that shadows the broken bundled cqlsh on PATH. Included from axonops::cassandra, gated on node['axonops']['cassandra']['cqlsh_venv']['enabled'] (default true). Skipped with a warning when offline_install is set (pip cannot reach PyPI) or on an unrecognised platform_family, so it never aborts a Cassandra converge. Also fixes the cqlsh-based health probe in attributes/alerts.rb on 3.12+ hosts. Ports the axonops-ansible-collection cassandra role (cqlsh-venv.yml). Adds a ubuntu-24.04 kitchen platform, the cassandra-50-cqlsh-venv-ubuntu-2404 suite, a systemd docker image, a CI converge job, plus ChefSpec, InSpec and BDD coverage and docs/CHANGELOG updates. Refs #35 Signed-off-by: Sergio Rua <sergio@axonops.com>
Signed-off-by: Sergio Rua <sergio@axonops.com>
Signed-off-by: Sergio Rua <sergio@axonops.com>
Collaborator
Author
|
manually tested and confirmed [ec2-user@ip-172-31-55-86 ~]$ ls -l /usr/local/bin/cqlsh
-rwxr-xr-x. 1 root root 193 Jul 21 11:40 /usr/local/bin/cqlsh
[ec2-user@ip-172-31-55-86 ~]$ /usr/local/bin/cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionResetError(104, 'Connection reset by peer')}) |
rgooding
approved these changes
Jul 21, 2026
Adding ubuntu-24.04 as a global platform made every suite without an `includes` whitelist fan out onto it, so `kitchen converge cassandra-311-tar` and `cassandra-50-default` grew a ...-ubuntu-2404 instance. The kitchen-tar and kitchen-311 CI jobs only build the 22.04 and rocky systemd images, so those new instances failed on the missing axonops-systemd-ubuntu-2404 image. Exclude ubuntu-24.04 from the seven fan-out suites; it stays scoped to cassandra-50-cqlsh-venv-ubuntu-2404 (which whitelists it via includes). The suites that already use includes (rhel, pkg-debian) were unaffected. Signed-off-by: Sergio Rua <sergio@axonops.com>
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.
Summary
Cassandra's bundled
cqlsh(both tarball and distro package) uses a Python driver that imports stdlib modules removed in Python 3.12 (asyncore,imp), so it aborts at startup on hosts whose system Python is >= 3.12 — Ubuntu 24.04+ and Debian 13 — on bothtarandpkginstalls.This ports the fix already shipped in the
axonops-ansible-collectioncassandra role (roles/cassandra/tasks/cqlsh-venv.yml) to the Chef cookbook.Closes #35.
What it does
recipes/cqlsh_venv.rb: builds an isolated Python virtualenv at/opt/cassandra-cqlsh-venvwith the maintained standalonecqlshPyPI package, and installs a/usr/local/bin/cqlshwrapper that shadows the broken bundled cqlsh onPATH(/usr/local/binprecedes both$CASSANDRA_HOME/binand/usr/bin). System Python and the bundled cqlsh are left untouched.axonops::cassandra, gated onnode['axonops']['cassandra']['cqlsh_venv']['enabled'](defaulttrue; harmless on Python <= 3.11).offline_installis set (pip can't reach PyPI on airgapped hosts) or on an unrecognisedplatform_family.attributes/alerts.rbon 3.12+ hosts (it resolvescqlshfromPATH).Attributes (
node['axonops']['cassandra'])cqlsh_venv.enabledtruecqlsh_venv.path/opt/cassandra-cqlsh-venvcqlsh_venv.pythonpython3-m venvcqlsh_venv.packages['cqlsh']['cqlsh==6.2.0'])cqlsh_venv.wrapper_path/usr/local/bin/cqlshTesting
spec/unit/recipes/cqlsh_venv_spec.rb— enabled/disabled, Debian vs RHEL package sets, offline skip, custom attrs.test/integration/cassandra/controls/cqlsh_venv.rb— venv + wrapper present, PATH shadowing,cqlsh --versionruns withoutImportError.features/cassandra/installation.feature.ubuntu-24.04platform +cassandra-50-cqlsh-venv-ubuntu-2404suite +test/docker/Dockerfile.systemd-ubuntu-2404, exercising the distro that actually breaks the bundled cqlsh. New CI converge job in.github/workflows/test.yml(converge-only, matching the existing pattern — InSpec verify is license-gated).Docs
docs/CASSANDRA.md— new "cqlsh on Python 3.12+ hosts" section + TOC entry.CHANGELOG.md—[Unreleased] / Addedentry.Notes / open questions (carried from #35)
createsguard), so no auto-upgrade; documented manual upgrade path.cqlshpackage itself ever breaks on a future Python (3.13/3.14, Ubuntu 26.x), the venv would still fail — flagged as a known limitation.Assisted-by: Claude Code