feat: add replica count to scale mode, gate resource throttling on idle.replicas >= 1#909
Merged
Conversation
…le.replicas >= 1
Scale mode now has two distinct behaviors controlled by sablier.idle.replicas:
- idle.replicas=0 (default): workload is stopped on session expiry (same as
the default stop behavior). CPU/memory labels are ignored.
- idle.replicas>=1: workload keeps running at the given replica count.
CPU/memory throttling is applied when both idle/active resource labels are set.
New labels:
sablier.idle.replicas - replica count when idle (default 0, stops workload)
sablier.active.replicas - replica count when active (default 1)
Providers updated:
- Docker/Podman: skip ContainerUpdate when no CPU/memory labels are set
- Docker Swarm: ServiceUpdateScale combines replica + resource update in a
single ServiceUpdate call; fixes nil-pointer panic and missing memory
parsing when only replicas are set
- Kubernetes: scale() then scaleResources() called sequentially; scaleResources
is skipped when no CPU/memory labels are present
BREAKING CHANGE: sablier.idle.cpu / sablier.idle.memory no longer enable
throttling on their own. Add sablier.idle.replicas=1 to existing workloads
that relied on CPU/memory throttling.
Co-authored-by: GitHub Copilot <copilot@github.com>
Test Results✅ All tests passed! | 413 tests in 157.633s |
|
|
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 with a first-class replica count, making it possible to scale workloads to any replica count on session start/stop — not just toggle CPU/memory limits.
Closes #28
Closes #258
New labels
sablier.idle.replicas00stops the workload (default).≥ 1keeps it running with optional resource throttling.sablier.active.replicas1Behavior change
Resource throttling (
sablier.idle.cpu/sablier.idle.memory) now only activates whensablier.idle.replicas >= 1.Previously, adding CPU/memory labels alone was enough. Now you must also set
sablier.idle.replicas=1explicitly.Migration: add
sablier.idle.replicas=1to any workload that usedsablier.idle.cpuorsablier.idle.memory.Scaling to more than 1 replica
Replicas-only mode (no CPU/memory throttling) is also supported:
Provider changes
ContainerUpdateis skipped when no CPU/memory labels are set (replicas only)ServiceUpdateScalereplaces the separate replica + resource update calls — oneServiceUpdateround-trip. Fixes nil-pointer panic and missing memory parsing when CPU label is absentscale()then optionalscaleResources()called sequentially; resources step is skipped when no CPU/memory labels are presentTests added
sablier.idle.replicas/sablier.active.replicaslabel parsingDocumentation
docs/configuration.md: new label table rows, updated scale mode section, added Docker Swarm exampleexamples/scale-mode/README.md: documents the breaking change, shows multi-replica usage, replicas-only usage