feat(docker): add blkio throttling support to scale mode#935
Open
acouvreur wants to merge 1 commit into
Open
Conversation
Add BlkioWeight and per-device blkio fields to ResourceProfile so that scale mode can throttle block I/O when a container goes idle and restore it when the container wakes up. Changes: - pkg/sablier/instance.go: add BlkioWeight, BlkioWeightDevice, BlkioDeviceReadBps, BlkioDeviceWriteBps, BlkioDeviceReadIOps, BlkioDeviceWriteIOps to ResourceProfile; add parseWeightDevices and parseThrottleDevices helpers; wire 10 new sablier labels in ScaleConfigFromLabels; update HasResources to include all blkio fields - pkg/provider/docker/container_scale.go: refactor applyResources to build container.Resources with all six blkio fields; add parseBpsRate, parseIOpsRate, parseBlkioWeight helpers - pkg/provider/docker/container_start.go: call applyResources with active profile - pkg/provider/docker/container_stop.go: call applyResources with idle profile - pkg/provider/docker/container_scale_unit_test.go: unit tests for parseBlkioWeight, parseBpsRate, parseIOpsRate, parseCPUNano, parseMemoryBytes - pkg/sablier/scale_test.go: unit tests for new label parsing - pkg/provider/docker/container_scale_test.go: integration tests using DinD; BlkioWeight tests pass; device throttle tests skip in environments where Docker silently drops the update (moby/moby#52650) - pkg/provider/docker/testcontainers_test.go: enable cgroupv2 io controller in DinD after startup Note: BlkioDeviceReadBps, BlkioDeviceWriteBps, BlkioDeviceReadIOps, BlkioDeviceWriteIOps, and BlkioWeightDevice are accepted by the API but currently silently ignored by the Docker daemon when updating a running container (see moby/moby#52650). The fields are included so that they become effective once the upstream issue is resolved.
|
Test Results✅ All tests passed! | 542 tests in 211.922s
|
|
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
Extends scale mode to support block I/O throttling via
BlkioWeightand per-device blkio fields. When a container goes idle, Sablier can now apply blkio constraints; when the container wakes up, the original (active) profile is restored — all without restarting the container.New labels
sablier.idle.blkio-weight100sablier.active.blkio-weight500sablier.idle.blkio-weight-device/dev/vda:100sablier.idle.blkio-device-read-bps/dev/vda:10msablier.idle.blkio-device-write-bps/dev/vda:10msablier.idle.blkio-device-read-iops/dev/vda:100sablier.idle.blkio-device-write-iops/dev/vda:100Multiple devices can be specified with commas:
/dev/vda:10m,/dev/vdb:5m.Changes
pkg/sablier/instance.go—ResourceProfilegains six blkio fields;ScaleConfigFromLabelsparses 10 new labels;HasResourcescovers all fieldspkg/provider/docker/container_scale.go—applyResourcesbuildscontainer.Resourceswith all blkio fields; newparseBpsRate/parseIOpsRate/parseBlkioWeighthelpers (human-friendly units:10m= 10 MB/s)pkg/provider/docker/container_start.go/container_stop.go— callapplyResourceswith active/idle profileBlkioWeight(pass) and device throttle (skip with explanation when unsupported, see below)Known upstream limitation
BlkioDeviceReadBps,BlkioDeviceWriteBps,BlkioDeviceReadIOps,BlkioDeviceWriteIOps, andBlkioWeightDeviceare currently silently ignored by the Docker daemon when updating a running container — the API returns 200 OK but the cgroup is not updated.Root cause:
daemon/update_linux.go:toContainerdResourcesonly mapsBlkioWeightintospecs.LinuxBlockIO; the five per-device fields are never converted.Tracked upstream: moby/moby#52650
The fields are included in Sablier today so they become effective as soon as the upstream issue is resolved, without requiring a Sablier release. Integration tests skip (rather than fail) in environments where Docker silently drops the update.