fix(serverless): default workersStandby to workersMin so workers=(0, N) scales to zero - #372
Draft
justinwlin wants to merge 1 commit into
Draft
fix(serverless): default workersStandby to workersMin so workers=(0, N) scales to zero#372justinwlin wants to merge 1 commit into
justinwlin wants to merge 1 commit into
Conversation
…N) scales to zero Deploying with workers=(0, 1) omitted workersStandby from the saveEndpoint payload, so the RunPod API applied its own default and the endpoint held a warm worker forever instead of scaling to zero. ServerlessResource now defaults workersStandby to workersMin and validates explicit values against the (workersMin, workersMax) range, so the deployed config matches the requested one. Endpoint also accepts an optional workers_standby parameter for overriding the standby count explicitly.
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
workers=(min, max)did not setworkersStandbywhen building thesaveEndpointcreate/update payload — the field was simply absent from the model, so the RunPod API applied its own server-side default. Deploying withworkers=(0, 1)producedworkersMin: 0andworkersStandby: 1: the endpoint kept one warm worker forever and never scaled to zero, invisibly. This PR defaultsworkersStandbytoworkersMin(with explicit-override support), so the deployed config matches the requested scaling range.Fixes #364
Internal: CON-1229
What changed
src/runpod_flash/core/resources/serverless.py— new optionalworkersStandbyfield onServerlessResource; a model validator defaults it toworkersMinwhen unset and validates explicit values against the(workersMin, workersMax)range. Because the deploy/update payloads are built frommodel_dump(), both create and update now sendworkersStandby.src/runpod_flash/endpoint.py— new keyword-onlyworkers_standbyparam onEndpoint, range-validated and passed through to the resource config (issue suggestion ux update to terminal #2). When omitted, the resource default (workersMin) applies.docs/Flash_SDK_Reference.md— documentworkers_standbyand the standby-follows-minbehavior next toworkers.tests/unit/resources/test_serverless.py,tests/unit/test_endpoint.py— 12 new tests:workers=(0, 1)yieldsworkersMin: 0/workersStandby: 0in the deploy payload,workers=(2, 5)yieldsworkersStandby: 2, explicit overrides respected, out-of-range values raise.Notes
workersStandbyis intentionally not in_hashed_fields, soresource_ididentity is unchanged. It does enter the exclude-basedconfig_hash; for legacy pickled resources the field is simply absent (verifiedconfig_hash/model_dumpdon't error), so the first deploy after upgrade detects drift once and issues a non-structuralsaveEndpointupdate that corrects standby on existing endpoints.workersMin=1defaults.How verified
pytest tests/unit/test_endpoint.py tests/unit/resources/test_serverless.py tests/unit/resources/test_live_serverless.py— 342 passed.pytest tests/unit— 2570 passed, 3 failed; the same 3 tests fail identically at the base commit (unrelated pre-existing test-ordering issues intest_load_balancer_sls_stub.py/test_regressions.py; they pass in isolation).ruff format+ruff check— clean.mypy .— same 260 pre-existing errors as the base commit (error set identical modulo line shifts).ServerlessResource(noworkersStandbyin instance state):config_hash,resource_id, andmodel_dumpall work.Confirmed via mocked payloads only — no live RunPod deploy was run.