Skip to content

fix(migrations): skip non-directory entries under keyspaces/ - #192

Merged
nvjmcnamee merged 1 commit into
NVIDIA:mainfrom
sureshkrishnan-ai:fix/migrations-skip-non-directory-keyspaces
Jul 17, 2026
Merged

fix(migrations): skip non-directory entries under keyspaces/#192
nvjmcnamee merged 1 commit into
NVIDIA:mainfrom
sureshkrishnan-ai:fix/migrations-skip-non-directory-keyspaces

Conversation

@sureshkrishnan-ai

@sureshkrishnan-ai sureshkrishnan-ai commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

TL;DR

migrations/cassandra/keyspaces/ holds README.md alongside the four keyspace directories, and execute_sqls.sh iterated over every entry, so README.md was 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.md was 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:

Successfully initialized the db
SQL files pre-processed successfully
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 cassandra-helm-nvcf-cassandra-migrations Helm hook job and leaves the cassandra release in a failed state.

The first loop also creates an empty /tmp/keyspaces/README.md directory on the way through, which is why the guard is applied to both loops rather than only the one that calls migrate. The [ -d ] form was chosen over a .dockerignore for *.md because it also covers any other non-directory file added to keyspaces/ 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 the keyspaces/README.md defect, now tracked as #235 (split out of #190 at maintainer request). The base-image defect (#190, the FROM bitnami/cassandra:5.0.6 base 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-r7 builds 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.md present in keyspaces/:

--- loop with the [ -d ] guard (this PR):
  SKIP (not a dir): README.md
  keyspace: api_keys_api
  keyspace: ess_api
  keyspace: nvcf_api
  keyspace: sis_api
--- same loop without the guard (current main):
  keyspace: README.md          <- the bug
  keyspace: api_keys_api
  ...

End to end, against Cassandra 5.0.x running in a local k3d cluster: with README.md present in the build context the migrations hook job fails as quoted above; with the same image built from a context where README.md is removed, the job completes and the schema applies. This change makes the README.md-present case behave like the README.md-absent case.

bash -n migrations/cassandra/execute_sqls.sh is clean.

QA needed: no, beyond a normal migrations run.

Issues:

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

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 in tools/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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved database migration handling by ignoring unexpected files in keyspace directories.
    • Prevented non-keyspace files from interrupting migration processing.

@nvjmcnamee

Copy link
Copy Markdown
Contributor

@sureshkrishnan-ai thanks for the PR. This mentions fixing #190 which actually contains two separate defects. Would you mind splitting that into two issues so that we can track correctly?

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#235

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Suresh Krishnan <sureshkrishnan.ai@gmail.com>
@sureshkrishnan-ai
sureshkrishnan-ai force-pushed the fix/migrations-skip-non-directory-keyspaces branch from 78bf7f8 to 468751c Compare July 17, 2026 10:35
@sureshkrishnan-ai
sureshkrishnan-ai requested a review from a team as a code owner July 17, 2026 10:35
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Cassandra migration script now skips non-directory entries while preprocessing keyspaces and executing migrations, preventing files such as README.md from being processed as keyspaces.

Changes

Cassandra migration filtering

Layer / File(s) Summary
Filter non-directory keyspace entries
migrations/cassandra/execute_sqls.sh
Both keyspace-processing loops now skip entries that are not directories.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: borao

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR changes keyspace filtering in execute_sqls.sh, but linked issue #190 only tracks the Cassandra Dockerfile base-image failure. Update the PR to address the missing Cassandra base image for #190, or retarget it to the runtime keyspaces issue (#235).
Out of Scope Changes check ⚠️ Warning The script change is unrelated to the only linked issue, which is about the Cassandra Dockerfile base image. Either include the base-image fix for #190 or relink the PR to the runtime keyspaces issue it actually addresses.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: skipping non-directory entries under keyspaces/ during migrations.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sureshkrishnan-ai

Copy link
Copy Markdown
Contributor Author

Thanks @nvjmcnamee. Done: split #190 into two.

No code change in the PR itself, just the amended Fixes reference (force-pushed).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@migrations/cassandra/execute_sqls.sh`:
- Around line 57-60: The directory-filter guards in the migration script lack
regression coverage. Add a test that places a non-directory file such as
README.md alongside keyspace directories and verifies both preprocessing and
migration process only directories; if testing is not feasible, document the
omission in the merge-request description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0e166431-c715-4ddf-a81e-5c5b1e3c67da

📥 Commits

Reviewing files that changed from the base of the PR and between 8329fba and 468751c.

📒 Files selected for processing (1)
  • migrations/cassandra/execute_sqls.sh

Comment thread migrations/cassandra/execute_sqls.sh
@nvjmcnamee
nvjmcnamee added this pull request to the merge queue Jul 17, 2026
Merged via the queue into NVIDIA:main with commit c548885 Jul 17, 2026
16 checks passed
@balajinvda

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version nvcf-cassandra-migrations-v0.13.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migrations/cassandra: keyspaces/README.md is treated as a keyspace and fails the migration run

3 participants