Skip to content

feat(locations): add a cancel hook to the endpoints-to-locations backfill - #15701

Open
Maffooch wants to merge 1 commit into
bugfixfrom
claude/locations-migration-cancel-cf71c5
Open

feat(locations): add a cancel hook to the endpoints-to-locations backfill#15701
Maffooch wants to merge 1 commit into
bugfixfrom
claude/locations-migration-cancel-cf71c5

Conversation

@Maffooch

@Maffooch Maffooch commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

[sc-14596]

What

Adds a cooperative cancel_callback stealth option to migrate_endpoints_to_locations, so an in-process caller can stop a long backfill cleanly at the next chunk boundary. This is the OSS half of adding Cancel + re-run to the Locations data-migration suite; the user-facing button lives in Pro and consumes this hook.

Why

The endpoints backfill can run for a long time, and reportedly gets stuck with no way to stop it. There was no cancellation path in the command at all. Because each chunk is separately committed and the command is idempotent (it converges on re-run), stopping between chunks is safe and resumable.

How

  • cancel_callback() -> bool added to stealth_options and read in handle(), alongside the existing progress_callback / summary_callback.
  • _should_cancel() is polled at the chunk boundary, right after _emit_progress. A raising probe is treated as "keep going" (a transient error must not throw away hours of work), matching the existing swallow-and-continue convention for the other hooks.
  • On cancel the run breaks out of the loop but still runs the tag-inheritance pass for what it migrated (it's idempotent), and reports {"cancelled": True} in the summary so the caller can land the run as cancelled rather than completed.
  • CLI runs pass no callback and behave exactly as before.
  • Docs (PRO__migrating_from_endpoints, PRO__feature_flags) and the Pro changelog (v3.2.300) describe the Cancel behaviour.

Ordering

This must merge before the paired Pro PR: the Pro migration suite passes cancel_callback into call_command, which raises on an unknown stealth option until this ships in the image the Pro build consumes.

Testing

./run-unittest.sh --test-case unittests.test_migrate_endpoints_to_locations — 15/15 pass (4 new: cancel-between-chunks, re-run converges, raising probe doesn't abort, CLI path unchanged). manage.py check and makemigrations --check clean; ruff clean.

🤖 Generated with Claude Code

…fill

The endpoints backfill can run for a long time. Add a cooperative
cancel_callback stealth option, polled at the chunk boundary next to the
existing progress hook, so an in-process caller (the Pro migration suite) can
stop the run cleanly between chunks. Chunks are separately committed and the
class is idempotent, so a cancelled run leaves a consistent, resumable state.

- cancel_callback() -> bool added to stealth_options and read in handle().
- _should_cancel() polled after _emit_progress at the chunk boundary; a raising
  probe is treated as "keep going" so a transient error can't discard hours of
  work.
- On cancel the run still applies tag inheritance for what it migrated and
  reports {"cancelled": True} in the summary; CLI runs are unaffected.

Docs and the Pro changelog describe the new Cancel behaviour.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Maffooch
Maffooch requested a review from blakeaowens as a code owner August 18, 2026 04:13
@Maffooch Maffooch added this to the 3.2.300 milestone Aug 18, 2026
@Maffooch Maffooch modified the milestones: 3.2.300, 3.2.201 Aug 18, 2026
@Maffooch
Maffooch added this pull request to the merge queue Aug 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants