Repository navigation
perf(swarm): let a runtime create its services without resolving the image - #552
Open
antoinegg1 wants to merge 2 commits into
Open
antoinegg1 wants to merge 2 commits into
antoinegg1 wants to merge 2 commits into
Conversation
…image `docker service create` asks the image's registry for its digest before the manager schedules the task: about 2.2 s a service on a busy manager (0.03 s with `--no-resolve-image`), every time, for a tag every node already holds. A swarm runtime may now say `resolve_image: false`: its services are created with `--no-resolve-image`, each node running the image it holds under that name and pulling it only where it holds none. The default stays docker's way (the manager pins the digest), and a runtime that leaves the setting at its default is written down exactly as before, so an older Humanize still reads the settings file. - SwarmConfig.resolve_image and SwarmRuntime.resolve_image (default True); the swarm driver passes the runtime's on. - The settings loader takes a boolean field as true or false only. - Docs: the swarm runtime's table and settings.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The form has no row for it, and a runtime is made again from the form's rows, so correcting a swarm saved with `resolve_image: false` wrote it back as true, and its services were created resolving their image again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Why
docker service createasks the image's registry for the image's digest before the managerschedules the task. On a busy manager that is about 2.2 s per service; with
--no-resolve-imageit is 0.03 s (measured on our swarm manager, the same command with andwithout the flag). A runtime whose image every node already holds, or one pinned by digest,
gains nothing from the round trip. Our LOT trees create thousands of single-task services per
run (one manager resolved the tag 2,700 times in 11 h).
What
SwarmConfig.resolve_image: bool = True(hmz.coganchor.machines.swarm):Falseadds--no-resolve-imagetodocker service create; nothing else changes.SwarmRuntime.resolve_image: bool = True(hmz.coganchor.machines.store): a swarmruntime's setting, passed on by the swarm driver (
environing_swarm)._typed) takes a boolean field astrueorfalseonly (it refusedevery boolean before; no runtime had one).
_fieldsleavesresolve_imageout while it isTrue, so a runtime that keeps docker'sway is written down byte for byte as before and an older Humanize still reads the file.
docs/reference/machines.md) andsettings.md.Behaviour
Default unchanged: the manager resolves the tag and pins the digest for every node. With
resolve_image: falseeach node runs the image it holds under that name and pulls it onlywhere it holds none, so nodes that hold different images under the same tag may run different
ones. That is the caller's choice; the docs say when it is safe (an image pinned by digest, or
the same image on every node).
Tests
tests/unit/coganchor/machines/test_swarm.py: the flag only when asked, before the image,and the command otherwise identical.
tests/unit/coganchor/machines/test_runtimes.py: defaultTrueand left out ofheld();falsekept and read back;0and"no"refused.tests/unit/runtime/flowing/test_environing_swarm.py: the runtime's setting reaches theservice's config (both ways).
pytest tests/unit/coganchor/machines/test_swarm.py tests/unit/coganchor/machines/test_runtimes.py tests/unit/runtime/flowing/test_environing_swarm.py: 264 passed.ruff checkandruff format --checkon the changed files andpyrighton the whole project (as pre-commit runs it): clean.🤖 Generated with Claude Code