feat(backend/docker): add per-step resource limits and OOM score adjustment#6735
Open
bclermont wants to merge 2 commits into
Open
feat(backend/docker): add per-step resource limits and OOM score adjustment#6735bclermont wants to merge 2 commits into
bclermont wants to merge 2 commits into
Conversation
…stment
Add support for per-step memory, CPU limits and OOM score adjustment
in the Docker backend via backend_options in workflow YAML:
steps:
build:
image: golang:1.22
backend_options:
docker:
resources:
limits:
memory: 1g
cpus: 1.5
oom_score_adj: 500
- Memory accepts human-readable strings (512m, 1g) and overrides the
global WOODPECKER_BACKEND_DOCKER_LIMIT_MEM when set
- CPUs (float) converted to Docker NanoCPUs
- oom_score_adj restricted to [0, 1000] by design — steps can only be
made more likely to be OOM-killed, never protected
- Per-step limits override agent-level global limits when set
- JSON schema updated for linter support
- Documentation updated with examples and option reference table
6543
reviewed
Jun 15, 2026
| if err != nil { | ||
| return nil, err | ||
| } | ||
| memLimit = parsed |
Member
There was a problem hiding this comment.
we need checks, golbal conf should be able to be limited but not widen
this allows to overwrite conf.resourceLimit.MemLimit to have a greater limit!
Contributor
Author
There was a problem hiding this comment.
@6543 should I just change it to never go beyond WOODPECKER_BACKEND_DOCKER_LIMIT_MEM ?
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
Add support for per-step memory, CPU limits and OOM score adjustment in the Docker backend via
backend_optionsin workflow YAML.Motivation
The Docker backend currently only supports global resource limits via agent environment variables (
WOODPECKER_BACKEND_DOCKER_LIMIT_MEM, etc.). There is no way to cap individual heavy steps without affecting all steps globally. This leads to OOM situations where the host server freezes because no step-level ceiling exists.Changes
BackendOptionsstruct withresources.limits.{memory,cpus}andoom_score_adjtoHostConfignow acceptsBackendOptionsand merges per-step limits over global agent limitsparseMemoryhelper supportingk/m/gsuffixesoom_score_adjrestricted to [0, 1000] by design — steps can only be made more killable, never protected from the OOM killerbackend_options.dockertoHostConfigmerge logicUsage
resources.limits.memory512m,1g). OverridesWOODPECKER_BACKEND_DOCKER_LIMIT_MEM.resources.limits.cpus0.5,1.5). Converted to NanoCPUs.oom_score_adj0= default,1000= kill first. Negative values rejected by design.