Skip to content

[FastDeploy2] Clean orphan staging files - #12310

Open
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-cleanup-fastdeploy2-staging
Open

[FastDeploy2] Clean orphan staging files#12310
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-cleanup-fastdeploy2-staging

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • clean /data/local/tmp/fastdeploy2/<package>/<user> entries for packages that are no longer installed
  • run cleanup only on cold deployments, at most once per device every 24 hours, with a 24-hour staging age guard
  • query installed packages once per Android user and fail closed on missing tools, command errors, or ambiguous output
  • add private $(_AndroidFastDeploySkipCleanup) and $(_AndroidFastDeployForceCleanup) escape hatches
  • cover forced cleanup with an MSBuildDeviceIntegration test that creates a fresh orphan staging file and verifies it is deleted
  • document FastDeploy2 command compatibility and approximate Android API support

Validation

  • built Xamarin.Android.Build.Debugging.Tasks.csproj
  • validated the generated cleanup command with shell syntax checking
  • validated Xamarin.Android.Common.Debugging.targets as XML

The device integration test requires the repository's .NET 11 local SDK and a connected device, which are not available in this worktree.

Automatically remove old staging directories for packages that are no longer installed. Run cleanup only on cold deployments, rate-limit it per device, and fail closed on unsupported or ambiguous device state.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80e378d0-3374-44f9-9b1c-692ac97297a7
Copilot AI review requested due to automatic review settings August 7, 2026 16:42

Copilot AI 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.

Pull request overview

This PR adds a FastDeploy2 “cold deploy” maintenance step to clean up orphaned on-device staging directories under /data/local/tmp/fastdeploy2/<package>/<user> when the corresponding package is no longer installed, with rate limiting and a safety window. It also wires a private MSBuild escape hatch to skip the cleanup, adds a unit test for the generated shell command, and documents command/tool compatibility expectations.

Changes:

  • Implement orphan staging cleanup shell command generation and invoke it on the cold deployment path (rate-limited, safety-window guarded).
  • Add $(_AndroidFastDeploySkipCleanup)FastDeploySkipCleanup task wiring as an internal escape hatch.
  • Add a unit test for the cleanup command structure and extend FastDeploy2 documentation (including command compatibility notes).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DebuggingTasksTests.cs Adds a unit test validating key fragments/order of the generated cleanup command.
src/Xamarin.Android.Build.Debugging.Tasks/Xamarin.Android.Common.Debugging.targets Passes the new MSBuild property into the FastDeploy2 task invocation.
src/Xamarin.Android.Build.Debugging.Tasks/Tasks/FastDeploy2.Manifest.cs Adds cleanup command generation + execution helper (adb shell) for orphan staging directories.
src/Xamarin.Android.Build.Debugging.Tasks/Tasks/FastDeploy2.cs Adds the FastDeploySkipCleanup task property and runs cleanup only on the cold path.
Documentation/guides/FastDeploy2.md Documents the new escape hatch, the cleanup behavior, and command compatibility expectations.

jonathanpeppers and others added 2 commits August 7, 2026 11:59
Replace the generated-command assertion with a device integration test and add a private property that forces cleanup while preserving mutual exclusion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80e378d0-3374-44f9-9b1c-692ac97297a7
Run forced cleanup through the existing cold deployment path and use the force property only to bypass cleanup guards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80e378d0-3374-44f9-9b1c-692ac97297a7
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

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

Reviewed the full diff and surrounding implementation. I found no correctness or safety defects in the fail-closed cleanup logic. I left one non-blocking test-coverage suggestion for the production safety guards.

CI is still in progress: 29 of 44 checks have completed successfully, 14 are running, and the aggregate check remains queued; no failures are currently reported.

Generated by Android PR Reviewer for #12310 · gpt56 · 132.7 AIC · ⌖ 10.1 AIC · ⊞ 25.3K
Comment /review to run again

};
proj.SetDefaultTargetDevice ();
proj.SetProperty ("_AndroidFastDevStrategy", "FastDeploy2");
proj.SetProperty ("_AndroidFastDeployForceCleanup", "true");

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.

🧪 Suggestion: This forces both the 24-hour rate limit and the 24-hour age guard to zero, so the test only covers unconditional deletion. Since this feature runs rm -rf on shared device state, please also exercise at least one production safety invariant—ideally that staging for an installed package is retained, and/or that a fresh orphan survives the default safety window. That would catch a regression in the package-enumeration or age-check logic that this forced path cannot detect.

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.

2 participants