feat: per-job max_runtime to cap rsync/rclone wall-clock duration#16
Merged
feat: per-job max_runtime to cap rsync/rclone wall-clock duration#16
Conversation
…ero/negative messages
New status constant for jobs killed by per-invocation deadline. IsFailure returns true so Summary.HasErrors and the CLI exit-code path treat it as a failure. statusSymbol maps it to ✗ (red); itemStatsText renders "timed out" (red when color enabled). aggregateStatus already classifies any IsFailure status as StatusFailed at the aggregate level — no changes needed there.
Adds classifyExitStatus(ctx, runErr) in runner.go. Both RsyncExecutor and RcloneExecutor route their cmd.Start and cmd.Wait exit paths through it: context.DeadlineExceeded maps to StatusTimedOut; context.Canceled and other errors remain StatusFailed. Covers both the Start path (already-expired context rejects the spawn) and the Wait path (deadline fires mid-run). Five-subtest classifier unit test pins the "deadline first then parent cancel" ordering guarantee; two executor integration tests use WithDeadline(past) to exercise the full path.
Adds jobContext helper that wraps the parent context with WithTimeout when max_runtime is set, or returns the parent unchanged (with a no-op cancel) when it is empty. Wires the derived context into runRsyncJob (synchronous cancel per source loop iteration) and runRcloneJob (defer cancel). CleanupArchives keeps the parent context unchanged.
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
Adds a
max_runtime = "2h"field on[[job]]entries that caps the wall-clock duration of each rsync/rclone invocation. When a job exceeds its budget, Shuttle kills the tool and reports a new✗ timed outstatus (counts as a failure, exit 1). Applies per invocation: a job with N rsync sources or N rclone remotes gets N independent timeouts.CleanupArchivesdeliberately keeps the parent context so housekeeping can't fail a job.The classification helper (
classifyExitStatus) distinguishes deadline-exceeded contexts from parent cancellation, so SIGINT/SIGTERM still maps to exit 130 — only the per-job deadline producesStatusTimedOut.