Pre start init containers#13862
Draft
glours wants to merge 2 commits into
Draft
Conversation
Temporary replace directive pointing to a compose-go fork that exposes PreStart hooks on types.ServiceConfig. To be removed once a compose-go release with these fields is published. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
runPreStart executes a service's pre_start hooks sequentially as ephemeral containers sharing the first service replica's volumes via VolumesFrom and attached to the same networks. A non-zero hook exit gates service start. per_replica: false is the only currently supported mode; per_replica: true is rejected up front. The log stream is opened before ContainerStart to avoid racing AutoRemove on fast-exiting hooks, and ContainerWait uses WaitConditionNextExit to block until the run actually finishes. pre_start runs once per service when no replica is already running (initial up, force-recreate or spec change), and is skipped on scale-up so additional replicas don't re-trigger the hooks. E2E coverage: success path, hook failure gating start, build-image inheritance, idempotent re-up, re-run on spec change, force-recreate, mid-sequence failure, sequential ordering, no re-run on scale-up, and once-per-service for scaled services. Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
ff47ea5 to
8e44596
Compare
Contributor
Author
|
/review |
|
❌ PR Review Failed — The review agent encountered an error and could not complete the review. View logs. |
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.
What I did
Add support for the
pre_startservice lifecycle hook from the compose spec.Hooks run as ephemeral containers before a service's containers start, sharing the first replica's volumes via
VolumesFromand attached to the same networks. A non-zero hook exit gates service start.Semantics:
up,--force-recreate, spec change).scale up.per_replica: trueis rejected up front; onlyper_replica: falseis supported for now.build:); overridable per hook.Covered by 8 unit tests and 10 E2E tests (success, failure gating, build inheritance, idempotent re-up, spec change, force-recreate, mid-sequence failure, ordering, scale-up, scaled service).
Note: the first commit adds a temporary
replaceto acompose-gofork exposingPreStartonServiceConfig. To be reverted once a propercompose-gorelease lands.Related issue
compose-spec/compose-spec#11 & compose-spec/compose-spec#291
(not mandatory) A picture of a cute animal, if possible in relation to what you did
