Skip to content

Keep a running mover's pid file when the plugin is installed or removed - #281

Merged
chodeus merged 1 commit into
masterwishx:betafrom
chodeus:fix/keep-running-mover-pid
Nov 11, 2026
Merged

chodeus merged 1 commit into
masterwishx:betafrom
chodeus:fix/keep-running-mover-pid

Conversation

@chodeus

@chodeus chodeus commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator
  • Installing, updating or removing the plugin deleted /var/run/mover.pid unless age_mover was running. Unraid's own mover and a share's Move write that file too.
  • An update during one of those runs hid the run: a second mover could start on top of it, mover stop (which Unraid runs when the array stops) answered "not running", and the Mover Tuning tab showed no run.
  • The pid file is now removed only when its pid is not a mover. A stale file is still cleared, also when another process has since taken its pid.
  • A run the plugin started keeps all its files and blocks removal, from its before script to its after script. Unraid's own mover keeps its pid file and does not block removal.
  • Tested with real processes in a container, 18 cases for each script: Unraid's mover, a forced move, a share's Move, age_mover started the old and the new way, a run still in its before script, a mover that starts during the cleanup, and stale, reused and unreadable pid files. The old code fails eight of them.

Summary by CodeRabbit

  • Bug Fixes
    • Active Mover Tuning runs are no longer disrupted by post-install cleanup.
    • Removing the plugin is now prevented while a Mover Tuning run is active, while Unraid’s built-in mover does not block removal.
    • Cleanup now preserves mover-related run state and avoids removing a process ID file associated with a running mover.

The install and remove scripts read "age_mover is not running" as "no mover
is running" and deleted /var/run/mover.pid. Unraid's own mover and
share_mover write that file too, so a plugin update during one of their
runs hid the run: a second mover could start on top of it, and "mover
stop", which Unraid calls when the array stops, reported "not running".

mover.pid is now removed only when its pid is not a mover, and only while
the file still holds that pid. A run the plugin started (age_mover,
share_mover, or with_scripts from the before script on) keeps all its
files and blocks removal. Unraid's own mover keeps its pid file and does
not block removal.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Post-install and removal cleanup now check for active Mover Tuning processes before changing run-state files. Both paths remove mover.pid only when it is not associated with a mover and its contents have not changed since they were read.

Changes: Mover cleanup lifecycle

Layer / File(s) Summary
Active-run cleanup safeguards
plugins/ca.mover.tuning.plg
Post-install cleanup and removal detect age_mover, share_mover, and the plugin’s with_scripts process. They preserve run-state files while a plugin run is active. Removal does not block for Unraid’s built-in mover. Both paths conditionally remove mover.pid based on its recorded process and whether the PID file changed.

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

Change: Bug fix

Possibly related PRs

  • masterwishx/ca.mover.tuning#274: Adds run-state files and changes pause/resume behavior for plugin-started mover runs, which are also handled by this PR’s cleanup changes.

Suggested reviewers: masterwishx

Merge Risk: Minimal · up to 06fd6

The change keeps a running mover's pid file during plugin install or removal and still clears stale files. No concrete merge-blocking issue was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: preserving a running mover’s PID file during plugin installation or removal.
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 unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d04a83c and 06fd68c.

Files selected for processing: 1

  • plugins/ca.mover.tuning.plg

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@chodeus

chodeus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

@chodeus
chodeus marked this pull request as ready for review November 11, 2026 01:40
@chodeus
chodeus merged commit 76bfab1 into masterwishx:beta Nov 11, 2026
9 checks passed
@chodeus
chodeus deleted the fix/keep-running-mover-pid branch November 11, 2026 01:40
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