Add per-job hourly log quota enforced on runner#3668
Merged
peterschmidt85 merged 5 commits intomasterfrom Mar 17, 2026
Merged
Conversation
Prevents runaway log costs by limiting log output per job per calendar hour. Default quota is 50MB/hour, configurable via DSTACK_SERVER_LOG_QUOTA_PER_JOB_HOUR (0 disables). Jobs exceeding the quota are terminated with reason log_quota_exceeded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
r4victor
reviewed
Mar 17, 2026
un-def
reviewed
Mar 17, 2026
Avoids susceptibility to wall clock adjustments (e.g., NTP sync) by tracking elapsed hours from a monotonic start time instead of calendar-hour boundaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lity JobSpec is sent client→server as part of RunPlan.current_resource, so new fields break older servers. log_quota_hour is only needed server→runner, so it belongs on SubmitBody instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without Field(include=True), pydantic's .json() drops fields that lack an include annotation when other fields in the model use Field(include=...). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
un-def
approved these changes
Mar 17, 2026
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
DSTACK_SERVER_LOG_QUOTA_PER_JOB_HOURenv var (bytes, 0 disables)errorand reasonlog quota exceededChanges
Go (runner)
types.go: AddTerminationReasonLogQuotaExceededconstantschemas.go: AddLogQuotaHourfield toJobSpeclogs.go: Add quota tracking toappendWriterwith out-of-band signaling via channel (needed because ansistrip is async and swallows downstream errors)executor.go: AddcopyOutputWithQuota()method, wire quota viaSetJob(), handle quota error inRun()executor_test.go: AddTestExecutor_LogQuotaPython (server)
runs.py: AddLOG_QUOTA_EXCEEDEDtoJobTerminationReason(maps toFAILED), addlog_quota_hourtoJobSpecsettings.py: AddSERVER_LOG_QUOTA_PER_JOB_HOURsetting (default 50MB)runner.py: Addlog_quota_hourtoSubmitBodyinclude setbase.py: Add_log_quota_hour()method, wire into_get_job_spec()Test plan
TestExecutor_LogQuotapassesgo test ./...)log quota exceededlog quota exceededdstack ps -vshows statuserrorand errorlog quota exceededdstack logsshows partial logs captured before termination🤖 Generated with Claude Code