feat: scope worker names to stack slug and add --name-template#68
Merged
Conversation
Preset cpu/gpu worker aliases were hardcoded (worker_cpu_0, ...) and
not stack-scoped, so worker containers spawned by different stacks
sharing a host docker daemon collided — unlike the server/redis/volume
names, which all carry the stack slug. Default preset names are now
prefixed with the stack slug (flowmesh_node[_<suffix>]_worker_*), and
worker up gains --name-template ({slug}/{kind}/{idx}/{gpu}) for custom
naming, with a duplicate-name guard within a single invocation.
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Catch ValueError from format_map so a malformed --name-template (e.g. unbalanced braces) surfaces a clean FlowMeshError instead of an uncaught traceback. Remove the unreachable "No GPUs detected" check — both GPU branches always append at least one spec. Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
Route the default cpu/gpu naming through the same format_map path as a user-supplied --name-template by synthesizing the default template, so there is a single rendering site. Output is unchanged. Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
…g6j-4rv6-33pg pip-audit's strict server scan flagged aiohttp 3.13.5 for two upstream advisories, both fixed in 3.14.0. Raise the floor, re-lock (resolves 3.14.1), and regenerate the worker requirements files. Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
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.
Purpose
flowmesh stack worker up cpu|gpugenerated preset worker aliases from hardcoded, non-namespaced names (worker_cpu_0,worker_gpu_0, …). The server'sDockerWorkerFactoryuses the alias verbatim as the worker name and as the basis for the container name, but worker containers spawned by every stack share the host docker daemon namespace. Unlike the server / redis / volume names, which all carry the stack slug (flowmesh_node[_<suffix>]_*), these worker names were not stack-scoped, so two stacks differentiated byFLOWMESH_STACK_SUFFIXon the same host produced colliding worker containers.This scopes preset worker names to the stack slug by default and adds a
--name-templatefor custom naming.Changes
sdk/stack/src/flowmesh_stack/workers.py:create_workers/_payloads_for_worker_creategainname_templateandslugparams (both defaultNone, so direct SDK callers and the--configpaths keep today's behavior). New_worker_aliashelper builds{slug}_worker_{kind}_{idx|gpu}by default, or renders a template over{slug}/{kind}/{idx}/{gpu}via a strict format dict that raises a clearFlowMeshErroron an unknown placeholder. Generated aliases are deduped within one invocation.cli/stack/src/flowmesh_cli_stack/worker.py:worker upgains--name-template, resolves the stack slug from env (reusingstack_resource_env_overrides/STACK_SLUG_ENV, which read the already-loadedFLOWMESH_STACK_SUFFIX), and passes both down. An invalid suffix exits cleanly.docs/CLI.md: document the slug-prefixed default naming and--name-templatewith its placeholders.tests/sdk/test_workers.py: cover slug-prefixed defaults, legacy bare names, template rendering, the unknown-placeholder error, the duplicate-name guard, and GPU single/multi cases.Design
The default name is not expressed as a template string; it is the existing per-kind logic with a slug prefix, so GPU workers keep their informative
_gpu_<id>/_gpu_allsuffix.--name-templateis a full override; when present it alone determines the alias. To prevent the obvious foot-gun (a template without{idx}/{gpu}forcount > 1), all generated aliases are checked for uniqueness within a singleupinvocation and a missing-disambiguator template fails fast. The default prefix is the full stack slug (flowmesh_node+ optional suffix), matching the convention every other stack-managed object already follows.Test Plan
End-to-end (
flowmesh stack worker up/list/down): default and suffix-scoped naming, cross-stack isolation (two stacks, no collision),--name-templaterendering, fail-fast on bad templates, and GPU naming (single / per-GPU /--targets all/ template).Test Result
End-to-end scenarios above all passed, including GPU workers on a 2-GPU host — every worker came up healthy with a correctly slug-prefixed name and no collisions.
Pre-submission Checklist
pre-commit run --all-filesand fixed any issues.uv run pytest tests/passes locally.uv sync --all-packages --group ci --frozen).[BREAKING]and described migration steps above.