fix(migrations): skip non-directory entries under keyspaces/#192
Open
sureshkrishnan-ai wants to merge 1 commit into
Open
fix(migrations): skip non-directory entries under keyspaces/#192sureshkrishnan-ai wants to merge 1 commit into
sureshkrishnan-ai wants to merge 1 commit into
Conversation
migrations/cassandra/keyspaces/ holds README.md alongside the four keyspace directories. execute_sqls.sh iterated over every entry, so README.md was treated as a keyspace and passed to migrate as x-migrations-table=README.md. The golang-migrate Cassandra driver reads the dot in that value as keyspace.table, so it tried to open a keyspace named README, which Cassandra lowercases: error: failed to open database: Keyspace 'readme' doesn't exist Migration failed for /tmp/keyspaces/README.md execute_sqls.sh then exits 1, which fails the Helm hook job and leaves the cassandra release in a failed state. Guard both loops with [ -d ] so only directories are treated as keyspaces. This also covers any other non-directory file added to keyspaces/ later. Fixes NVIDIA#190 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Suresh Krishnan <sureshkrishnan.ai@gmail.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.
TL;DR
migrations/cassandra/keyspaces/holdsREADME.mdalongside the four keyspace directories, andexecute_sqls.shiterated over every entry, soREADME.mdwas treated as a keyspace and aborted the migration run. This guards both loops with[ -d ]so only directories are treated as keyspaces.Additional Details
README.mdwas passed tomigrateasx-migrations-table=README.md. The golang-migrate Cassandra driver reads the dot in that value askeyspace.table, so it tried to open a keyspace namedREADME, which Cassandra lowercases:execute_sqls.shthen exits 1, which fails thecassandra-helm-nvcf-cassandra-migrationsHelm hook job and leaves thecassandrarelease in afailedstate.The first loop also creates an empty
/tmp/keyspaces/README.mddirectory on the way through, which is why the guard is applied to both loops rather than only the one that callsmigrate. The[ -d ]form was chosen over a.dockerignorefor*.mdbecause it also covers any other non-directory file added tokeyspaces/later.The four real keyspaces (
api_keys_api,ess_api,nvcf_api,sis_api) are unaffected.For the Reviewer
Single file, six lines, no behaviour change for directories.
This fixes defect 2 of #190 only. Defect 1 in that issue (the
FROM bitnami/cassandra:5.0.6base no longer resolving, since Bitnami withdrew their public catalog in Aug 2025) is deliberately not addressed here, because the right replacement looks like a maintainer decision rather than something to presume:bitnamilegacy/cassandra:5.0.5-debian-12-r7builds and runs, but it is a version downgrade, and an internal mirror may be preferred. Happy to follow up with a PR once you indicate a direction.For QA
Verified against the fixed image built with
README.mdpresent inkeyspaces/:End to end, against Cassandra 5.0.x running in a local k3d cluster: with
README.mdpresent in the build context the migrations hook job fails as quoted above; with the same image built from a context whereREADME.mdis removed, the job completes and the schema applies. This change makes theREADME.md-present case behave like theREADME.md-absent case.bash -n migrations/cassandra/execute_sqls.shis clean.QA needed: no, beyond a normal migrations run.
Issues:
Checklist
On tests: there is no existing test harness for the shell scripts under
migrations/(no BUILD target, no bats or shell test suite, and no migrations entry intools/ci/subproject-validations.yaml), so there was no natural place to add one for a six-line guard. Happy to add coverage if you want a harness introduced, or to fold it into whatever you would prefer here.