Repository navigation
refactor: the worker runs executions without a saga, and cancel stops the pod - #428
Merged
Merged
Conversation
… the pod The saga orchestrator, k8s worker, result processor and pod monitor passed commands to each other through Kafka inside one process. The new execution scheduler keeps the Redis queue and calls the k8s worker directly; the pod monitor hands finished pods to the result processor, which stores the result before it publishes anything, then frees the slot. Cancel now stores the execution as cancelled and deletes its pod. Before, only the saga was marked and the pod ran to the end. The saga documents, routes, admin page, saga and pod command events go. The worker's consumer group keeps the name saga-orchestrator so its committed offsets carry over.
…duler The two shared the name scheduler in start_jobs. The entrypoint test now checks the function each job calls.
…s group The worker's two subscribers join saga-orchestrator seconds apart, so the group can be Stable before the request consumer has partitions, and a request sent then is skipped on a fresh Kafka.
HardMax71
enabled auto-merge (squash)
October 20, 2026 21:53
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
|
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
The worker ran one job as four services that sent each other commands through Kafka inside one process, and their copies of an execution's state drifted apart. Cancelling a running execution only marked the saga and freed its slot (saga_orchestrator.py), so the pod ran on, the execution ended as completed and the next queued run started beside it.
Changes
A new execution scheduler keeps the Redis queue and calls the k8s worker directly. The pod monitor hands a finished pod to the result processor and frees its slot. The processor writes first and publishes only if the write applied, so a cancelled pod's late failure sends nothing. Cancel stores
cancelled, then deletes the pod. The saga goes with its routes, admin page, 300 s timeout and the saga and pod command events. The worker's group keeps the namesaga-orchestratorso its offsets carry over.Warning
Stored events and DLQ rows of the removed types no longer load, and the event pages fail on them until they're gone. Right after the deploy, on prod MongoDB:
Type of Change
Test Plan
cd backend && uv run pytest tests/unit)cd frontend && npm run test)docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e')cd frontend && npm run test:e2e)./deploy.sh openapi, then./deploy.sh types), never edited by handValidation: backend e2e on k3s with this branch's worker gives 463 passed, 1 skipped (main collects 494; the 30 saga tests went). The cancel test now checks the stored
cancelled. CI's e2e-ready also waits for a consumer onexecution_requested, since the worker's two subscribers join seconds apart. The unit, contract, Vitest, lint, type and docs gates pass.Checklist
pre-commit run --all-filesand all checks passSummary by cubic
The worker no longer runs executions through a saga. A new execution scheduler pulls from the Redis queue and tells the k8s worker to start a pod directly; the pod monitor hands finished pods to the result processor, which writes the result before publishing anything and then frees its slot. Before, the four services inside the worker passed commands to each other over Kafka and kept drifting copies of the same execution state.
Cancelling a run previously only marked the saga and freed its slot, so the pod ran to completion. Cancel now stores the execution as
cancelledand deletes its pod, ending the run at once. The saga orchestrator, its API and admin pages, and the saga and pod command events are removed; the worker's group keeps the namesaga-orchestratorso its Kafka offsets carry over.Migration
Written for commit d4edbe3. Summary will update on new commits.