Skip to content

feat(cassandra): build the runtime image with Bazel (rules_oci) - #358

Closed
balajinvda wants to merge 4 commits into
mainfrom
feat/cassandra-bazel-image
Closed

feat(cassandra): build the runtime image with Bazel (rules_oci)#358
balajinvda wants to merge 4 commits into
mainfrom
feat/cassandra-bazel-image

Conversation

@balajinvda

@balajinvda balajinvda commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Why

The custom Apache-Cassandra runtime image (infra/cassandra, from #328) has no build/push CI, and the existing image builds are all Bazel rules_oci. Give it a Bazel build so it releases the same way as every other NVCF image (no buildah/Dockerfile one-off).

What changed

  • infra/cassandra: nested Bazel module. oci.pull cassandra:5.0.8 (multi-arch by digest), layer checksummed yq (public http_file) + the rack-aware cassandra-env.sh, set the exporter --add-opens JVM opts, expose 9500. bazel build //:image_index is green and carries linux/amd64 + linux/arm64; a yq exec-bit sh_test guards the layer.
  • Public target ships no exporter agent (OSS-safe). The Prometheus exporter layer + the nvcr.io/0651155215864979/ncp-dev/cassandra push live in the OSS-excluded infra/cassandra/nvidia-internal/ overlay (shared //rules/oci-destinations macro) — same split as stargate.
  • rules_python toolchain sets ignore_root_user_error (the root-in-CI trap stargate hit). .bazelignore + a cassandra matrix row wired.

Open item

The metrics-enabled release variant needs one input: the exporter agent jar's internal URL + sha256 (a marked placeholder in rules/repos.bzl). Until then the public no-exporter image builds; the internal variant resolves its full graph and fails only on that one fetch.

Notes

The Dockerfile stays in place during the transition; retiring it + wiring the nvcf-internal type: bazel release is the follow-up once this lands.

References

None

Summary by CodeRabbit

  • New Features

    • Added reproducible, multi-architecture Cassandra runtime OCI image builds for Linux AMD64 and ARM64, including the yq utility, Cassandra environment config, JVM compatibility --add-opens settings, and port 9500 exposure.
    • Added CI-friendly build stamping metadata for stable version tracking.
  • CI/CD

    • Expanded Bazel change-detection to include the Cassandra subtree in the build/test matrix.
    • Added validations for image entrypoint executability and Cassandra version consistency.
  • Documentation

    • Updated Cassandra image build guidance, including Bazel build/test/packaging commands and multi-arch module usage.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b0937c3c-e8e5-4d6c-ae95-f88b50fbb385

📥 Commits

Reviewing files that changed from the base of the PR and between a8785b1 and b583f79.

📒 Files selected for processing (5)
  • infra/cassandra/AGENTS.md
  • infra/cassandra/BUILD.bazel
  • infra/cassandra/MODULE.bazel
  • infra/cassandra/tools/ci/BUILD.bazel
  • infra/cassandra/tools/ci/cassandra_version_consistency_test.sh
🚧 Files skipped from review as they are similar to previous changes (4)
  • infra/cassandra/tools/ci/BUILD.bazel
  • infra/cassandra/MODULE.bazel
  • infra/cassandra/AGENTS.md
  • infra/cassandra/BUILD.bazel

📝 Walkthrough

Walkthrough

Adds infra/cassandra as a nested Bazel module with pinned dependencies, multi-architecture OCI image rules, Cassandra image layers, yq artifact packaging, CI detection, validation scripts, and workspace status stamping.

Changes

Cassandra Bazel image

Layer / File(s) Summary
Nested module and build setup
.bazelignore, .github/workflows/bazel.yml, infra/cassandra/.bazel*, infra/cassandra/.gitignore, infra/cassandra/MODULE.bazel, infra/cassandra/platforms/*, infra/cassandra/rules/*, infra/cassandra/tools/*, infra/cassandra/AGENTS.md
Defines the nested Bazel module, pins Bazel 9.1.1, configures supported platforms and build profiles, and adds CI detection and build documentation.
Multi-architecture OCI rule pipeline
infra/cassandra/rules/oci/*
Adds OCI helper rules that apply platform transitions, assemble amd64 and arm64 images, create an image index, and expose Docker-load outputs.
Cassandra image assembly and artifacts
infra/cassandra/BUILD.bazel, infra/cassandra/rules/repos.bzl
Downloads digest-pinned yq binaries, packages yq and Cassandra environment layers, and builds the public Cassandra image with port and JVM settings.
Image validation and build stamping
infra/cassandra/tools/ci/*, infra/cassandra/tools/workspace_status.sh
Validates yq permissions, Cassandra version consistency, and image entrypoint executability while emitting Git- and build-derived workspace metadata.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant Bazel
  participant ExternalArtifacts
  participant OCIImage
  CI->>Bazel: select infra/cassandra subtree
  Bazel->>ExternalArtifacts: fetch pinned yq binaries
  ExternalArtifacts-->>Bazel: provide amd64 and arm64 artifacts
  Bazel->>OCIImage: assemble Cassandra layers
  OCIImage-->>CI: produce multi-architecture image index
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits and accurately summarizes the PR’s Bazel-based Cassandra runtime image build.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cassandra-bazel-image

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

balajinvda and others added 3 commits July 22, 2026 13:48
Give the custom Apache-Cassandra runtime image (infra/cassandra) a Bazel
rules_oci build so it releases through the same flow as every other NVCF image
instead of a Dockerfile/buildah one-off.

- infra/cassandra: nested Bazel module. oci.pull cassandra:5.0.8 (multi-arch, by
  digest), layer in a checksummed yq (public http_file) and the rack-aware
  cassandra-env.sh, set the exporter JVM --add-opens, expose 9500. Multi-arch
  image_index (amd64 + arm64) builds green; a yq exec-bit test guards the layer.
- Public target ships NO exporter agent (OSS-safe). The Prometheus exporter
  layer and the ncp-dev push live in the OSS-excluded infra/cassandra/nvidia-internal
  overlay, via the shared //rules/oci-destinations macro.
- rules_python toolchain sets ignore_root_user_error (rules_pkg needs it under
  the root CI container). Matrix row + .bazelignore wired.

Follow-up: the internal (with-metrics) release variant needs the exporter agent
jar's URL + sha256 (placeholder in rules/repos.bzl); the Dockerfile stays until
the release cuts over.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…public build

The public Bazel image is exporter-free by design: the cassandra-exporter
agent jar is internal-only and never redistributed in the OSS snapshot. The
earlier scaffold left a dead `@cassandra_exporter_agent` http_file
(EXPORTER-JAR-URL-TODO.invalid) plus a nvidia-internal/ overlay in the tree so
the with-exporter variant would analyze. With the umbrella scrub retired, an
in-repo nvidia-internal/ path is no longer excluded from the public mirror, so
that overlay and the jar must not live here at all.

Remove the placeholder repo from rules/repos.bzl, MODULE.bazel, and the
lockfile, drop the untracked overlay, and reword the AGENTS.md/BUILD.bazel
notes: the with-exporter image is built in the private release repo
(nvcf-internal), which injects its own nvidia-internal/ overlay and jar into
this module at release time and reuses the public yq/env layers.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
The nvcf-internal bazel release backend builds every service image with
`--config=release` for a uniform invocation. The Cassandra image is pure
assembly (no compiled targets), so `-c opt` is effectively a no-op, but the
config must exist or `bazel build --config=release` errors with an undefined
config. Define it so the shared release script runs unmodified.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
@balajinvda
balajinvda force-pushed the feat/cassandra-bazel-image branch from 5001c87 to a8785b1 Compare July 22, 2026 20:57
@balajinvda
balajinvda marked this pull request as ready for review July 22, 2026 20:58
@balajinvda
balajinvda requested a review from a team as a code owner July 22, 2026 20:58
@balajinvda
balajinvda requested a review from nvjmcnamee July 22, 2026 21:01

@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 `@infra/cassandra/MODULE.bazel`:
- Around line 66-72: Establish a single validated Cassandra version contract: in
infra/cassandra/MODULE.bazel lines 66-72, derive or validate the pinned manifest
digest against the version used by the Dockerfile instead of maintaining them
independently; in infra/cassandra/AGENTS.md lines 52-55, replace the conflicting
bump guidance with synchronized instructions requiring the Dockerfile tag and
Bazel digest to be updated and verified together.
🪄 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: c8e5facd-d6b1-4c61-908e-9b4fba9c389a

📥 Commits

Reviewing files that changed from the base of the PR and between 44c5fac and a8785b1.

⛔ Files ignored due to path filters (1)
  • infra/cassandra/MODULE.bazel.lock is excluded by !**/*.lock, !**/MODULE.bazel.lock
📒 Files selected for processing (20)
  • .bazelignore
  • .github/workflows/bazel.yml
  • infra/cassandra/.bazelrc
  • infra/cassandra/.bazelversion
  • infra/cassandra/.gitignore
  • infra/cassandra/AGENTS.md
  • infra/cassandra/BUILD.bazel
  • infra/cassandra/MODULE.bazel
  • infra/cassandra/platforms/BUILD.bazel
  • infra/cassandra/rules/BUILD.bazel
  • infra/cassandra/rules/oci/BUILD.bazel
  • infra/cassandra/rules/oci/defs.bzl
  • infra/cassandra/rules/oci/private/BUILD.bazel
  • infra/cassandra/rules/oci/private/common.bzl
  • infra/cassandra/rules/oci/transition.bzl
  • infra/cassandra/rules/repos.bzl
  • infra/cassandra/tools/BUILD.bazel
  • infra/cassandra/tools/ci/BUILD.bazel
  • infra/cassandra/tools/ci/image_entrypoint_mode_test.sh
  • infra/cassandra/tools/workspace_status.sh

Comment thread infra/cassandra/MODULE.bazel Outdated
…MODULE.bazel

CodeRabbit flagged that the pinned oci.pull digest and the transitional
Dockerfile `FROM cassandra:<tag>` are maintained independently while both are
described as the source of truth, so a future bump could ship divergent
versions.

Make the digest authoritative and add an enforceable contract: record the
resolved tag in a `# cassandra-version:` marker beside the digest, and add
cassandra_version_consistency_test, which fails the build if the Dockerfile tag
and the marker disagree. Reword the MODULE.bazel and AGENTS.md guidance into a
single synchronized bump procedure (digest, marker, Dockerfile tag together).

The test asserts the two human-maintained version strings agree; it does not
resolve the digest over the network. The Dockerfile stays as a transitional
manual/dev build path.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
@balajinvda
balajinvda enabled auto-merge July 22, 2026 21:31

@nvjmcnamee nvjmcnamee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If porting the Dockerfile is the desired direction (which I am not sure about yet), then a lot of this should be moved to a module so it can be reused (e.g. migrations).

However, I am not convinced that using Bazel here is the right approach.

@balajinvda

Copy link
Copy Markdown
Contributor Author

Closing in favor of the Dockerfile approach. Per discussion: images that only assemble a base image (cassandra, and next openbao + migrations) will stay as a Dockerfile built through the release pipeline's type: dockerfile backend, rather than a Bazel rules_oci port. Bazel + rules_oci remains for services we actually compile (Go/Rust/Java). infra/cassandra on main is already Dockerfile-only, so nothing to revert.

@balajinvda balajinvda closed this Jul 22, 2026
auto-merge was automatically disabled July 22, 2026 23:02

Pull request was closed

@balajinvda
balajinvda deleted the feat/cassandra-bazel-image branch July 22, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants