Skip to content

fix(install): preserve comma in daemon.json on Jetson JP6 setup - #1895

Closed
swqa-saiy wants to merge 1 commit into
NVIDIA:mainfrom
swqa-saiy:fix/jetson-daemon-json-comma
Closed

fix(install): preserve comma in daemon.json on Jetson JP6 setup#1895
swqa-saiy wants to merge 1 commit into
NVIDIA:mainfrom
swqa-saiy:fix/jetson-daemon-json-comma

Conversation

@swqa-saiy

@swqa-saiy swqa-saiy commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

The sed command in setup-jetson.sh stripped the trailing comma from "default-runtime": "nvidia," after removing the iptables and bridge lines, producing malformed JSON that prevented Docker from starting.

Remove the comma-stripping substitution and keep only the line deletions so the resulting daemon.json remains valid.

Fixes #1875

Summary

The sed command in setup-jetson.sh for JP6 had three operations: delete the iptables line, delete the bridge line, and strip the trailing comma from "default-runtime": "nvidia,". The third substitution is fragile — depending on key ordering in daemon.json, it can produce invalid JSON or silently no-op. Since deleting the two lines is sufficient, the substitution is removed.

Related Issue

Fixes #1875

Changes

  • Remove the unnecessary s/"default-runtime": "nvidia",/"default-runtime": "nvidia"/ substitution from the JP6 sed command
  • Keep only the two d (delete line) operations which are sufficient

Type of Change

  • Code change for a new feature, bug fix, or refactor.
  • Code change with doc updates.
  • Doc only. Prose changes without code sample modifications.
  • Doc only. Includes code sample changes.

Testing

Verified against sample daemon.json files with various key orderings on a JP6 device — JSON remains valid after the fix in all cases.

Summary by CodeRabbit

  • Chores
    • Improved Jetson setup to more robustly update Docker daemon configuration: safer handling of malformed configuration files, atomic updates with cleanup on failure, preservation of original file permissions, and removal of obsolete Docker keys to ensure more reliable post-setup behavior.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The scripts/setup-jetson.sh configure_jetson_host() logic was replaced with a Python-driven patch for /etc/docker/daemon.json. The new code checks for python3, loads (and attempts to auto-repair) JSON, ensures a top-level dict, removes iptables and bridge keys, and writes the file back atomically while preserving mode.

Changes

Cohort / File(s) Summary
Docker daemon JSON patch
scripts/setup-jetson.sh
Replaced an inline sed edit with a Python-based routine: verifies python3 availability, parses daemon.json (attempts a known missing-comma auto-repair), asserts the top-level object is a dict, removes "iptables" and "bridge" keys, and writes the updated JSON atomically while preserving file permissions and cleaning up on failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I found a comma gone astray,
So I hopped in with Python play,
I fixed the JSON, pruned what’s spare,
Wrote it safe with gentle care,
Now Docker wakes — hooray hooray! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 accurately describes the main fix: addressing a comma preservation issue in daemon.json during Jetson JP6 setup.
Linked Issues check ✅ Passed The PR addresses the core requirement from issue #1875: fixing malformed daemon.json that prevents Docker from starting after JP6 installation.
Out of Scope Changes check ✅ Passed The changes are focused solely on fixing the daemon.json modification logic in configure_jetson_host() for JP6 setup, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/setup-jetson.sh`:
- Line 53: Replace the brittle line-based deletion of keys (the "${SUDO[@]}" sed
-i '/"iptables": false,/d; /"bridge": "none"/d' invocation) with a JSON-safe,
parser-based edit: use jq to read the daemon.json, delete the "iptables" and
"bridge" keys (e.g. jq 'del(.iptables, .bridge)'), write atomically to a temp
file and move it into place under sudo (preserving permissions), and then
restart Docker; this guarantees valid JSON regardless of key order or trailing
commas.
🪄 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: Pro Plus

Run ID: 1e63efc3-0cec-48e3-946e-13f38a1f4d95

📥 Commits

Reviewing files that changed from the base of the PR and between 8fac9d6 and 9127ef8.

📒 Files selected for processing (1)
  • scripts/setup-jetson.sh

Comment thread scripts/setup-jetson.sh Outdated
@wscurran

Copy link
Copy Markdown
Contributor

✨ Thanks for submitting this PR, which proposes a way to fix an issue with the daemon.json file on Jetson JP6 with Docker.


Possibly related open issues:

@cjagwani cjagwani self-assigned this Apr 15, 2026
@cjagwani
cjagwani requested a review from brandonpelfrey April 15, 2026 20:33
@cjagwani

Copy link
Copy Markdown
Collaborator

@swqa-saiy Thanks for catching this — the comma-stripping sed is definitely the bug. However #1913 replaces the entire sed approach with a Python JSON parser, which is more robust and fixes the same issue (#1875). Recommending we merge #1913 instead since it eliminates the class of bug entirely rather than patching one instance.

Your diagnosis in the issue was spot on though — it helped both PRs land.

@swqa-saiy
swqa-saiy force-pushed the fix/jetson-daemon-json-comma branch from 9127ef8 to 3e66b39 Compare April 16, 2026 02:44
The sed command in setup-jetson.sh stripped the trailing comma from
"default-runtime": "nvidia," after removing the iptables and bridge
lines, producing malformed JSON that prevented Docker from starting.

Remove the comma-stripping substitution and keep only the line
deletions so the resulting daemon.json remains valid.

Fixes NVIDIA#1875

Signed-off-by: swqa-saiy <swqa-saiy@users.noreply.github.com>

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/setup-jetson.sh`:
- Around line 89-91: The current cfg.pop("iptables", None) and cfg.pop("bridge",
None) unconditionally remove user values; change this to preserve user-specified
settings by only deleting those keys when they match the old semantics — i.e.,
remove "bridge" only if cfg.get("bridge") == "none" and remove "iptables" only
if cfg.get("iptables") is exactly False; update the logic around the cfg
variable (the two pop calls) to perform these conditional checks before popping
so custom bridge names or true iptables settings are retained.
🪄 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: Pro Plus

Run ID: 12f2ff7c-32ac-4ed1-9437-fc3f16eb5b58

📥 Commits

Reviewing files that changed from the base of the PR and between 9127ef8 and 3e66b39.

📒 Files selected for processing (1)
  • scripts/setup-jetson.sh

Comment thread scripts/setup-jetson.sh
Comment on lines +89 to +91
# --- Remove unwanted keys ---
cfg.pop("iptables", None)
cfg.pop("bridge", None)

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.

⚠️ Potential issue | 🟠 Major

Preserve the old match semantics when deleting Docker keys.

These pop() calls now remove bridge and iptables regardless of value. The previous logic only stripped "bridge": "none" and "iptables": false, so this will also wipe user-defined values like a custom bridge name during JP6 setup.

Suggested fix
-# --- Remove unwanted keys ---
-cfg.pop("iptables", None)
-cfg.pop("bridge", None)
+# --- Remove only the JP6 defaults we intentionally override ---
+if cfg.get("iptables") is False:
+    cfg.pop("iptables", None)
+if cfg.get("bridge") == "none":
+    cfg.pop("bridge", None)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/setup-jetson.sh` around lines 89 - 91, The current
cfg.pop("iptables", None) and cfg.pop("bridge", None) unconditionally remove
user values; change this to preserve user-specified settings by only deleting
those keys when they match the old semantics — i.e., remove "bridge" only if
cfg.get("bridge") == "none" and remove "iptables" only if cfg.get("iptables") is
exactly False; update the logic around the cfg variable (the two pop calls) to
perform these conditional checks before popping so custom bridge names or true
iptables settings are retained.

@swqa-saiy

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1913 which covers the same fix with a more thoroughly reviewed implementation. Thanks @BenediktSchackenberg

@swqa-saiy swqa-saiy closed this Apr 16, 2026
@wscurran wscurran added area: packaging Packages, images, registries, installers, or distribution bug-fix PR fixes a bug or regression platform: container Affects Docker, containerd, Podman, or images platform: jetson Affects Jetson AGX Thor or Orin and removed area: packaging Packages, images, registries, installers, or distribution Platform: Jetson AGX Thor/Orin labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression platform: container Affects Docker, containerd, Podman, or images platform: jetson Affects Jetson AGX Thor or Orin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

daemon.json for docker bug

3 participants