Skip to content

restart: resolve entries under --restartdir#486

Open
alan-lira wants to merge 1 commit into
mpickpt:mainfrom
alan-lira:fix/restartdir-path-handling
Open

restart: resolve entries under --restartdir#486
alan-lira wants to merge 1 commit into
mpickpt:mainfrom
alan-lira:fix/restartdir-path-handling

Conversation

@alan-lira

@alan-lira alan-lira commented Jul 17, 2026

Copy link
Copy Markdown

Refs #485

Background

While validating distributed restart from two MPICH/Hydra nodes, I found that mana_restart --restartdir depends on the caller's current working directory. The wrapper lists rank entries from the supplied restart directory, but later opens the returned names as relative paths. My test environment therefore had to launch each restart process from inside the checkpoint root.

This PR removes that working-directory dependency and adds focused regression coverage.

What changes

  • Treat the default --restartdir as a normal two-argument option.
  • Report a clear error when --restartdir has no value.
  • Expand ~ and normalize the supplied path to an absolute directory.
  • Resolve every rank directory beneath the supplied restart directory.
  • Detect incomplete .tmp files through the full rank path.
  • Pass the normalized path to the lower half.
  • Move the --restartdir DIR pair after the other DMTCP options. The lower half replaces this pair with the rank-specific checkpoint image, so this keeps the resulting image in a deterministic final position.
  • Add deterministic tests using a fake lower half and coordinator command. The tests do not require MPI or a cluster.

Why this is useful

A restart directory should identify the checkpoint tree completely. Users should not also have to change into that directory before invoking mana_restart, especially when each MPI rank is started remotely by Hydra.

Validation

python3 -m py_compile bin/mana_restart ci/test-mana-restart.py
python3 ci/test-mana-restart.py -v
make -j$(nproc) mana
focused restart-wrapper tests: 5 tests passed

The new tests cover:

  • restart from an unrelated working directory;
  • absolute-path propagation;
  • incomplete .tmp detection;
  • missing --restartdir value;
  • ordering relative to other DMTCP options.

Scope

This PR intentionally does not change coordinator lifecycle, loader debug-symbol discovery, DMTCP source, MPI configuration, or cluster provisioning. Those topics are discussed separately in the umbrella issue.

Summary by CodeRabbit

  • Bug Fixes

    • Improved restart directory validation and error handling.
    • Restart directories are now resolved to absolute paths.
    • Detects temporary files in restart directories and reports a clear error.
    • Corrected restart option ordering for reliable checkpoint recovery.
    • Provides clearer errors when the restart directory value is missing.
    • Defaults the restart directory to the current directory when omitted.
  • Tests

    • Added automated coverage for restart directory handling and failure cases.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

bin/mana_restart now validates and normalizes --restartdir, rejects invalid restart contents, and reorders forwarded arguments. A new isolated unittest suite covers these behaviors and runs from ci/unit-test.sh.

Changes

Restart directory handling

Layer / File(s) Summary
Restart directory validation and argument ordering
bin/mana_restart
Adds defaulting, argument validation, absolute-path resolution, directory checks, .tmp detection, and final placement of the --restartdir pair.
Wrapper regression coverage
ci/test-mana-restart.py, ci/unit-test.sh
Adds isolated tests for valid, invalid, missing, reordered, and default restart directory inputs, then runs them in CI.

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

Possibly related issues

  • mpickpt/mana#485 — The changes implement the issue’s mana_restart --restartdir path-handling fixes and regression tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'restart: resolve entries under --restartdir' directly corresponds to the main change: improving --restartdir handling by normalizing paths, validating the directory, and resolving entries within it.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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: 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 `@bin/mana_restart`:
- Around line 33-34: Update the dmtcp_flags handling around the existing default
--restartdir append so ./ is added only when the user has not already supplied
--restartdir. Preserve the existing missing-value validation for a user-provided
flag, ensuring a bare --restartdir is not satisfied by the default value and
reports the intended missing-value error.

In `@ci/unit-test.sh`:
- Around line 25-26: Update the regression test invocation in unit-test.sh to
reference test-mana-restart.py through the existing SCRIPT_DIR variable,
ensuring it resolves correctly from the mpi-proxy-split/unit-test working
directory while preserving the current verbose execution and failure handling.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fbf4fd85-a761-4f3a-806e-b5d20f8b24ff

📥 Commits

Reviewing files that changed from the base of the PR and between f296e33 and 7aafe1b.

📒 Files selected for processing (3)
  • bin/mana_restart
  • ci/test-mana-restart.py
  • ci/unit-test.sh

Comment thread bin/mana_restart
Comment on lines +33 to +34
dmtcp_flags.extend(["--restartdir", "./"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Conditionally append --restartdir to avoid duplicating the argument.

Unconditionally extending dmtcp_flags introduces a bug when the user explicitly provides --restartdir. If the user passes --restartdir /path, this logic adds a second --restartdir ./ to the end of the argument list, which will be erroneously forwarded to the lower half.

Furthermore, if the user provides --restartdir without a value, the added flag (--restartdir) is treated as the missing value, bypassing the missing-value check entirely and failing with an incorrect "Restart directory doesn't exist" error instead.

🐛 Proposed fix to apply the default conditionally
-    dmtcp_flags.extend(["--restartdir", "./"])
+if "--restartdir" not in dmtcp_flags:
+    dmtcp_flags.extend(["--restartdir", "./"])
📝 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
dmtcp_flags.extend(["--restartdir", "./"])
if "--restartdir" not in dmtcp_flags:
dmtcp_flags.extend(["--restartdir", "./"])
🤖 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 `@bin/mana_restart` around lines 33 - 34, Update the dmtcp_flags handling
around the existing default --restartdir append so ./ is added only when the
user has not already supplied --restartdir. Preserve the existing missing-value
validation for a user-provided flag, ensuring a bare --restartdir is not
satisfied by the default value and reports the intended missing-value error.

Comment thread ci/unit-test.sh
Comment on lines +25 to +26
# Additional wrapper regression test.
python3 ci/test-mana-restart.py -v || exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Fix the path to the test script.

At this point in the script, the working directory is mpi-proxy-split/unit-test, so the relative path ci/test-mana-restart.py does not exist. This will cause the pipeline to fail with a "No such file or directory" error, which likely prevented CI from catching the bug in bin/mana_restart.

Use the $SCRIPT_DIR variable to correctly reference the script regardless of the current working directory.

🐛 Proposed fix
 # Additional wrapper regression test.
-python3 ci/test-mana-restart.py -v || exit 1
+python3 "$SCRIPT_DIR/test-mana-restart.py" -v || exit 1
📝 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
# Additional wrapper regression test.
python3 ci/test-mana-restart.py -v || exit 1
# Additional wrapper regression test.
python3 "$SCRIPT_DIR/test-mana-restart.py" -v || exit 1
🤖 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 `@ci/unit-test.sh` around lines 25 - 26, Update the regression test invocation
in unit-test.sh to reference test-mana-restart.py through the existing
SCRIPT_DIR variable, ensuring it resolves correctly from the
mpi-proxy-split/unit-test working directory while preserving the current verbose
execution and failure handling.

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