Skip to content

fix: resolve recovery boot dataset mountpoint - #36

Merged
SimonFair merged 7 commits into
mainfrom
fix/recovery-mounted-dataset-config
Jul 30, 2026
Merged

fix: resolve recovery boot dataset mountpoint#36
SimonFair merged 7 commits into
mainfrom
fix/recovery-mounted-dataset-config

Conversation

@SimonFair

@SimonFair SimonFair commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • resolve the reset target from mounted ZFS dataset paths rather than assuming the pool root mountpoint
  • retain the dataset list until config discovery completes
  • require exactly one safe boot config directory before deleting password files

Summary by CodeRabbit

  • Bug Fixes
    • Improved recovery of the Unraid configuration directory from imported ZFS boot pools by simplifying boot dataset handling and tightening path resolution to a single unambiguous, non-symlink location.
    • Added stronger validation and safer cleanup when mounts or directory discovery fail.
    • Updated the credential removal process and confirmation messaging to match the currently recovered credential artifacts, with verification that both expected files are removed.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

reset_unraid_password now validates one expected ZFS boot dataset, derives and validates its config directory, cleans up failed mounts, and removes and verifies config/passwd and config/shadow.

Changes

Password recovery

Layer / File(s) Summary
Config discovery and credential reset
scripts/menu_recovery.sh
The workflow validates the expected boot dataset and mount point, resolves a non-symlinked config directory under the temporary mount root, cleans up failures, and removes and verifies config/passwd and config/shadow.
Reset confirmation
scripts/menu_recovery.sh
The confirmation prompt now identifies config/passwd and config/shadow as the files to remove.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

I hop to the boot pool, cautious and spry,
One dataset mounts beneath the sky.
Symlinks turn back, stray paths flee,
Passwd and shadow leave safely.
Clean roots make a happy hare!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the required conventional commit prefix and accurately summarizes the recovery boot dataset mountpoint fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 fix/recovery-mounted-dataset-config
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/recovery-mounted-dataset-config

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.

@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 `@scripts/menu_recovery.sh`:
- Around line 50-54: Update the config discovery flow using
config_candidate_count, config_symlink_found, and config_dir to fail closed when
traversal encounters any error. Track the validated, resolved in-root directory
selected during scanning instead of overwriting config_dir with each raw
candidate, and only delete credentials after a complete scan confirms exactly
one valid directory.
🪄 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 Plus

Run ID: 80deae1a-8a0b-4a4a-b9a6-9221be1b7749

📥 Commits

Reviewing files that changed from the base of the PR and between de2cec9 and 58c9b6c.

📒 Files selected for processing (1)
  • scripts/menu_recovery.sh

Comment thread scripts/menu_recovery.sh Outdated

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

🧹 Nitpick comments (1)
scripts/menu_recovery.sh (1)

76-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated cleanup-and-fail boilerplate.

The zpool export ...; rmdir ...; ui_msg ...; return 1 sequence is duplicated across ~9 failure branches in this function. In credential-handling code, duplicated cleanup logic risks silent divergence if one branch is updated later and others aren't.

♻️ Proposed helper extraction
+reset_cleanup_fail() {
+    local pool_name="$1" mount_root="$2" message="$3"
+    zpool export "$pool_name" >/dev/null 2>&1 || true
+    rmdir "$mount_root" 2>/dev/null || true
+    ui_msg "Password Reset" "$message"
+    return 1
+}
+
 reset_unraid_password() {
     ...
     if ! zfs list -H -o name "$boot_dataset" >/dev/null 2>&1; then
-        zpool export "$pool_name" >/dev/null 2>&1 || true
-        rmdir "$mount_root" 2>/dev/null || true
-        ui_msg "Password Reset" "The expected boot dataset '$boot_dataset' was not found."
-        return 1
+        reset_cleanup_fail "$pool_name" "$mount_root" "The expected boot dataset '$boot_dataset' was not found."
+        return 1
     fi
     # ...repeat for each of the other ~8 failure branches
🤖 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 `@scripts/menu_recovery.sh` around lines 76 - 153, Extract the repeated zpool
export, mount-root removal, error dialog, and return-1 sequence into a local
helper for this recovery function, then replace each failure branch’s duplicated
cleanup-and-fail block with that helper while preserving each branch’s existing
message and failure behavior.
🤖 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.

Nitpick comments:
In `@scripts/menu_recovery.sh`:
- Around line 76-153: Extract the repeated zpool export, mount-root removal,
error dialog, and return-1 sequence into a local helper for this recovery
function, then replace each failure branch’s duplicated cleanup-and-fail block
with that helper while preserving each branch’s existing message and failure
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 343836a9-93ea-40c4-ba0b-a29312c1f4b6

📥 Commits

Reviewing files that changed from the base of the PR and between 58c9b6c and 46a766a.

📒 Files selected for processing (1)
  • scripts/menu_recovery.sh

@SimonFair
SimonFair merged commit 6c1d8b8 into main Jul 30, 2026
3 checks passed
@SimonFair
SimonFair deleted the fix/recovery-mounted-dataset-config branch July 31, 2026 07:54
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.

1 participant