fix(backups): skip stateless services during project policy fan-out - #860
Open
chbndrhnns wants to merge 1 commit into
Open
chbndrhnns wants to merge 1 commit into
chbndrhnns wants to merge 1 commit into
Conversation
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
Excludes stateless services (services without persistent volumes or supported database engines) when fanning out a project-default backup policy, preventing recurring false-alarm failures and batch status corruption.
Motivation
When a backup policy is configured at the project level (
policy.serviceId === null),BackupOrchestrator.enqueue()fans out across all enabled services in the project and spawns abackup_runfor each one.In multi-service projects (such as compose stacks with web, api, workers, reverse proxies, dashboards), stateless companion services almost never declare volumes or persistent bind mounts. When their backup runs execute,
VolumeCopyProducerthrows:Nothing to back up: no volumes or bind mounts found for service "<service>"...This causes two critical issues:
latestByPolicy, because the batch status is markedfailedif any child run failed (batchRuns.some(r => r.status === "failed")), a single stateless frontend or monitor marks the whole project's nightly backup as failed—even when companion database services (e.g. Postgres, Redis, volume mounts) succeeded.Explicit per-service backup policies (
policy.serviceId !== null) retain the fail-closed error behavior from #611 when a user explicitly targets a service that lacks storage.Related issue
Closes #859
Changes
apps/api:backup.orchestrator.ts: AddisBackupCandidateServicehelper checking whether a service has a recognized database image (detectDbImage), declared volumes (service.volumes), or an explicit custom command/path payload.backup.orchestrator.ts: Filter project-default fan-out to only candidate services. If a project has no candidate services at all, fail fast with a clear diagnostic message rather than spawning doomed runs.triggers/cron.ts: Handleenqueueskip gracefully in recurring tick handler with a warning log instead of throwing unhandled errors.apps/api/test:backup-run-durability.test.ts: Add test verifying stateless services are skipped during project fan-out while stateful services are enqueued.backup-run-durability.test.ts: Add test verifying an error is thrown when a project has no persistent services.Verification
Ran all backup test suites in
apps/api/test/modules/backups/:$ bun run test test/modules/backups/ Test Files 21 passed (21) Tests 240 passed (240)Typechecked and formatted:
$ bun x tsc -p tsconfig.json --noEmit $ bun x prettier --check apps/api/src/modules/backups/backup.orchestrator.ts apps/api/src/modules/backups/triggers/cron.ts apps/api/test/modules/backups/backup-run-durability.test.ts All matched files use Prettier code style!Checklist
bun run test,tsc, andbun formatall pass locally