Skip to content

feat(cardano-node): support custom mithril image overrides - #415

Merged
verbotenj merged 1 commit into
mainfrom
feat/custom-mithril-image
Jul 15, 2026
Merged

feat(cardano-node): support custom mithril image overrides#415
verbotenj merged 1 commit into
mainfrom
feat/custom-mithril-image

Conversation

@verbotenj

@verbotenj verbotenj commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Adds support for specifying a dedicated image, tag, and pullPolicy for the mithril-snapshot initContainer.

Sets default to unstable (0.13.19+) due to GCS closed-channel stream bug.

Note: The built-in mithril-client v0.13.9 in ghcr.io/blinklabs-io/cardano-node:11.0.1-1 has a closed-channel stream race condition bug on GCS (Download: could not write 0 bytes to stream). Suggest using ghcr.io/input-output-hk/mithril-client:latest-unstable (or v2617.0+).


Summary by cubic

Adds Helm values to override the mithril client image for the snapshot initContainer and hardens the init script for more reliable restores. Defaults to ghcr.io/input-output-hk/mithril-client:unstable with pull policy Always, runs the init as non‑root, and adds stricter digest checks to avoid the GCS closed‑channel bug in mithril-client v0.13.9.

  • New Features

    • Add .Values.mithril.image.{repository,tag,pullPolicy} for the mithril-snapshot initContainer (repository/tag fall back to node image/tag if unset); default ghcr.io/input-output-hk/mithril-client:unstable with Always pull policy.
    • Run init as non‑root (UID/GID 1000) and set pod fsGroup: 1000; add /app/bin to PATH; auto‑resolve default genesis and ancillary keys for mainnet and preview|preprod.
    • Remove jq; parse snapshot list via shell, validate non‑empty digest, and fail fast; ensure a clean unpack directory to prevent Mithril “Unpack directory is not empty” errors.
  • Dependencies

    • Bump chart to 0.8.6, appVersion to 11.0.1, and default node image to ghcr.io/blinklabs-io/cardano-node:11.0.1-1.

Written for commit 699fe78. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Updated the Cardano node deployment to version 11.0.1.
    • Added configurable Mithril client image settings for snapshot bootstrapping.
    • Improved automatic selection of network verification keys, including sensible defaults.
    • Enhanced snapshot digest retrieval during initialization.
  • Bug Fixes

    • Improved Mithril snapshot initialization across supported networks.
    • Ensured required command paths and permissions are available during bootstrap.

@verbotenj
verbotenj requested review from a team as code owners July 11, 2026 19:07
@verbotenj
verbotenj force-pushed the feat/custom-mithril-image branch from 219f588 to 45023fe Compare July 11, 2026 19:08
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The chart version and Cardano Node application version were updated. The default node image tag and dedicated Mithril client image configuration were added. The Mithril snapshot init container now uses the dedicated image settings, runs as root, updates PATH, and omits the jq dependency check. Verification key resolution gained network-specific defaults, and snapshot digest extraction now uses text processing on Mithril client JSON output.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding configurable Mithril image overrides for the cardano-node chart.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/custom-mithril-image

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.

@cubic-dev-ai cubic-dev-ai Bot 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.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread charts/cardano-node/templates/statefulset.yaml Outdated
Comment thread charts/cardano-node/values.yaml
@verbotenj
verbotenj force-pushed the feat/custom-mithril-image branch 5 times, most recently from a23f179 to 55314b4 Compare July 11, 2026 23:16

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 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 `@charts/cardano-node/templates/statefulset.yaml`:
- Around line 37-39: Replace the init container’s root-based securityContext
with a non-root configuration, and add a pod-level securityContext under
spec.template.spec using fsGroup set to the mithril-client image’s non-root
group ID. Remove runAsUser: 0 and runAsGroup: 0 while preserving
persistent-volume write access.
- Line 148: Update the SNAPSHOT_DIGEST lookup in the snapshot download script to
handle an empty result or failed mithril-client fetch explicitly before
continuing. Preserve pipe failure detection with set -o pipefail, and emit a
clear error or exit when no digest is obtained so the later download is not
attempted with an empty value.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d622284-e9fc-4a15-a08a-29879300fdea

📥 Commits

Reviewing files that changed from the base of the PR and between 5b02f8f and 55314b4.

📒 Files selected for processing (3)
  • charts/cardano-node/Chart.yaml
  • charts/cardano-node/templates/statefulset.yaml
  • charts/cardano-node/values.yaml

Comment on lines +37 to +39
securityContext:
runAsUser: 0
runAsGroup: 0

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Init container runs as root — consider fsGroup alternative.

Explicitly setting runAsUser: 0 and runAsGroup: 0 degrades the container's security posture. If this is needed for persistent-volume write access, a pod-level securityContext.fsGroup can grant the container group ownership of mounted volumes without root.

🔒️ Suggested alternative using fsGroup
        securityContext:
-          runAsUser: 0
-          runAsGroup: 0
+          runAsUser: 1000
+          runAsGroup: 1000
         image: {{ .Values.mithril.image.repository | default .Values.image.repository }}:{{ .Values.mithril.image.tag | default .Values.image.tag }}

And add at the pod level (under spec.template.spec):

      securityContext:
        fsGroup: 1000

This makes the volume writable by the container's group without running as root. Adjust the UID/GID to match the mithril-client image's non-root user.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
securityContext:
runAsUser: 0
runAsGroup: 0
securityContext:
runAsUser: 1000
runAsGroup: 1000
🤖 Prompt for 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.

In `@charts/cardano-node/templates/statefulset.yaml` around lines 37 - 39, Replace
the init container’s root-based securityContext with a non-root configuration,
and add a pod-level securityContext under spec.template.spec using fsGroup set
to the mithril-client image’s non-root group ID. Remove runAsUser: 0 and
runAsGroup: 0 while preserving persistent-volume write access.

else
echo "Fetching latest snapshot digest from ${AGGREGATOR_ENDPOINT}..."
SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | jq -r '.[0].hash')
SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | grep -o '"hash":"[^"]*' | head -n 1 | cut -d'"' -f4)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if mithril-client is referenced elsewhere in the repo with JSON parsing
rg -n 'mithril-client.*--json' --type yaml
rg -n 'snapshot list' --type yaml

Repository: blinklabs-io/helm-charts

Length of output: 162


🌐 Web query:

What is the JSON output format of "mithril-client cardano-db snapshot list --json"? Does it use compact or pretty-printed JSON?

💡 Result:

The mithril-client cardano-db snapshot list --json command produces a standard JSON-formatted output of available snapshots [1][2]. According to the project's source code, this output is generated using the serde_json::to_string function [3], which produces compact (minified) JSON, not pretty-printed JSON [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant template and nearby script context
grep -n -A40 -B40 'SNAPSHOT_DIGEST=' charts/cardano-node/templates/statefulset.yaml

# Look for shell options or any digest validation nearby in the same file
rg -n 'pipefail|set -e|SNAPSHOT_DIGEST|Failed to fetch snapshot digest|hash' charts/cardano-node/templates/statefulset.yaml

Repository: blinklabs-io/helm-charts

Length of output: 5694


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the surrounding section with line numbers for precise context
nl -ba charts/cardano-node/templates/statefulset.yaml | sed -n '110,180p'

Repository: blinklabs-io/helm-charts

Length of output: 202


🏁 Script executed:

#!/bin/bash
set -euo pipefail

nl -ba charts/cardano-node/templates/statefulset.yaml | sed -n '130,170p'

Repository: blinklabs-io/helm-charts

Length of output: 202


Guard the snapshot digest lookup in charts/cardano-node/templates/statefulset.yaml:148. If the fetch pipeline returns nothing, SNAPSHOT_DIGEST stays empty and the later download fails with a vague error; set -o pipefail would also stop the script on a failed fetch.

🤖 Prompt for 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.

In `@charts/cardano-node/templates/statefulset.yaml` at line 148, Update the
SNAPSHOT_DIGEST lookup in the snapshot download script to handle an empty result
or failed mithril-client fetch explicitly before continuing. Preserve pipe
failure detection with set -o pipefail, and emit a clear error or exit when no
digest is obtained so the later download is not attempted with an empty value.

@verbotenj
verbotenj force-pushed the feat/custom-mithril-image branch 4 times, most recently from 4545fa6 to b14d6ed Compare July 12, 2026 00:36
Adds support for specifying a dedicated image, tag, and pullPolicy for the mithril-snapshot initContainer.

Sets default pullPolicy to Always to ensure mutable tags (like latest-unstable) are always checked on restart.

Note: The built-in mithril-client v0.13.9 in ghcr.io/blinklabs-io/cardano-node:11.0.1-1 has a closed-channel stream race condition bug on GCS (Download: could not write 0 bytes to stream). Suggest using ghcr.io/input-output-hk/mithril-client:latest-unstable (or v2617.0+).
Signed-off-by: Ales Verbic <verbotenj@blinklabs.io>
@verbotenj
verbotenj force-pushed the feat/custom-mithril-image branch from b14d6ed to 699fe78 Compare July 14, 2026 21:58
@verbotenj
verbotenj merged commit a97dc4b into main Jul 15, 2026
6 checks passed
@verbotenj
verbotenj deleted the feat/custom-mithril-image branch July 15, 2026 19:27
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