pre_start hooks: per_replica: true is accepted by the schema but always rejected at runtime
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
The issue is in pkg/compose/pre_start.go where runPreStart validates hooks. The compose-spec model is in types/hooks.go. To implement, examine the reconciliation-plan work in #14221, specifically planPreStartHookRunners. Need to modify the planning to create one runner per hook per replica, adjust naming/labeling (e.g., com.docker.compose.hook-index), resolve VolumesFrom per replica, and update execution in execPreStartHook. Start by reading the existing validation and the skipped planning logic.
索引モデルが issue の本文から書いたものです。
説明
What this issue is about
pre_start hooks support a per_replica attribute in the compose-spec model (types.PreStartHook.PerReplica, compose-go's types/hooks.go): "runs the hook once per service replica instead of once per service." docker/compose's engine, however, does not implement it: runPreStart (pkg/compose/pre_start.go) validates every declared hook up front and rejects the whole service if any hook sets per_replica: true:
for i, hook := range service.PreStart {
if hook.PerReplica {
return fmt.Errorf("service %q pre_start[%d]: per_replica is not yet supported; remove per_replica or set it to false", service.Name, i)
}
}
So today, per_replica: true is accepted by the loader/schema but always a hard error at runtime — there is no path to actually use it.
Illustration
services:
app:
image: alpine
command: sleep infinity
deploy:
replicas: 3
pre_start:
- image: alpine
command: ["sh", "-c", "echo initializing replica"]
per_replica: true
$ docker compose up -d
service "app" pre_start[0]: per_replica is not yet supported; remove per_replica or set it to false
The only way to get this compose file to run at all today is to drop per_replica: true, at which point the hook runs once for the whole service (against the lowest-numbered replica only, per the current one-hook-one-runner model) instead of once per replica — a different, sometimes unacceptable behavior for hooks that need to prepare per-replica state (e.g. per-replica config files, per-replica volume initialization).
Suggested scope for an implementation
The reconciliation-plan work in #14221 (pre_start hook runners as first-class plan resources) planned one CreateHookContainer operation per declared hook, targeted at a single resolved replica. Supporting per_replica: true would mean planning one runner per hook × per replica instead, with:
- a deterministic name/label scheme distinguishing replicas (e.g. extending the existing
com.docker.compose.hook-indexlabel with a replica index, or a dedicated label), VolumesFromresolved against that replica rather than the lowest-numbered one,- the corresponding execution-phase change in
runPreStart/execPreStartHookto run and account for one runner per replica.
This issue only tracks the feature gap; the reconciliation-plan groundwork from #14221 already discussed and worked around it (see its planPreStartHookRunners, which explicitly skips planning entirely for a service with any per_replica: true hook, to avoid orphaning runners that could never execute).
- 主要言語
- Go
- スター
- 38.4k
- フォーク
- 5.9k
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 66
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
docker/compose のほかの issue
-
Epic: Move service selection into the backend API instead of pre-filtering the project in the CLIオープン
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
kind/bug status/0-triage
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
docker/compose#14345 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Watch: exec mode対応中かも @glours が 3 日前に担当しました。 オープンkind/feature
docker/compose#14326 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
kind/feature
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
[BUG] `start -p <name>` treats an optional (`required: false`) dependency as required再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Say in the changelog that the text-index update cannot be rolled back対応中かも @praetorianer777 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
praetorianer777/GoTome#275 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
SAP/crossplane-provider-btp#1118 ·
メンテナーはふだん 1 日以内に返信
-
benchmark: `make setup` fails because audit-exporter builds with Go 1.25.0 while go.mod requires 1.26.0対応中かも @xsvm が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
volcano-sh/volcano#6097 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area/infra backlog bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
praetorianer777/Stator#417 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信