-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add configurable cache bind for chroot #8973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds conditional host-cache bind-mounting to chroot helpers: Changes
Sequence Diagram(s)sequenceDiagram
participant Host
participant Script as mount_chroot / umount_chroot
participant TargetFS as target (chroot)
Host->>Script: optional ARMBIAN_CACHE_DIR env
Script->>Host: check host cache exists
alt host cache exists
Script->>TargetFS: ensure target/armbian/cache directory exists
Script->>TargetFS: mount --bind host_cache -> target/armbian/cache
Note right of Script: record mount in stack for cleanup
else host cache missing
Script->>Host: log warning / skip bind
end
Script->>TargetFS: perform other guarded mounts (tmp,var,tmp,run/user/0,proc,sys,dev,dev/pts)
Note right of Script: on error -> unmount recorded mounts in reverse order
Script->>TargetFS: umount target/armbian/cache (if recorded/mounted)
Script->>TargetFS: continue existing unmount sequence
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (3)📚 Learning: 2025-10-24T04:46:22.901ZApplied to files:
📚 Learning: 2025-06-12T21:03:39.686ZApplied to files:
📚 Learning: 2025-07-21T04:12:02.439ZApplied to files:
🔇 Additional comments (6)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/functions/general/chroot-helpers.sh (1)
1-41: Document ARMBIAN_CACHE_DIR and add error handling for filesystem mounts.The variable
ARMBIAN_CACHE_DIRis not documented anywhere in the codebase—it only appears in the implementation. The cache mount itself is well-implemented (checks directory existence, validates already-bound mount points, logs warnings), but the early mounts lack error handling: tmpfs, proc, sysfs, and/devbind mounts have no checks and will fail silently if permissions are denied or the target is read-only.
- Add ARMBIAN_CACHE_DIR to documentation (config/README.md or similar) with the default value and use case.
- Add error handling to the early mounts in
mount_chroot(lines 21–27), since they're prerequisite operations that determine success or failure of the entire chroot setup.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
lib/functions/general/chroot-helpers.sh(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/functions/general/chroot-helpers.sh (2)
lib/functions/image/initrd.sh (1)
update_initramfs(23-133)lib/functions/rootfs/rootfs-create.sh (1)
create_new_rootfs_cache_via_debootstrap(54-365)
🔇 Additional comments (1)
lib/functions/general/chroot-helpers.sh (1)
49-56: Cache unmount ordering is correct; no issues identified.Verification of call sites and the
umount_chrootfunction confirms:
- Cache unmount (lines 54–56) correctly executes before the proc/sys/dev/tmp/run cleanup loop (lines 58–69)
- All call sites properly pair
mount_chrootwithumount_chroot- Error handling with
|| trueallows partial failures without stopping cleanup- The implementation maintains proper mount/unmount semantics
| cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}" | ||
| if mountpoint -q "${target}/armbian/cache"; then | ||
| umount "${target}/armbian/cache" || true | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused variable assignment.
Line 53 declares and assigns cache_src, but it is never referenced. The unmount logic on lines 54–56 works correctly without it.
Apply this diff to remove the unused variable:
- cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
- if mountpoint -q "${target}/armbian/cache"; then
+ if mountpoint -q "${target}/armbian/cache"; then📝 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.
| cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}" | |
| if mountpoint -q "${target}/armbian/cache"; then | |
| umount "${target}/armbian/cache" || true | |
| fi | |
| if mountpoint -q "${target}/armbian/cache"; then | |
| umount "${target}/armbian/cache" || true | |
| fi |
🤖 Prompt for AI Agents
lib/functions/general/chroot-helpers.sh around lines 53 to 56: remove the unused
variable assignment "cache_src=\"${ARMBIAN_CACHE_DIR:-/armbian/cache}\"" on line
53 since it is never referenced; leave the subsequent mountpoint check and
umount logic intact and ensure no other code in the file expects that variable
before committing the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @benhoff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
Description
This reimplements this pull request, while fixing the edge case (hopefully). #8186
I don't have a bare metal device to test.
How Has This Been Tested?
I haven't checked this yet, I'll run it with a Qt buildout that I have
Checklist:
Please delete options that are not relevant.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.