pre_start hooks: per_replica: true is accepted by the schema but always rejected at runtime
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Go
- Star
- 38.4k
- Fork
- 5.9k
- Merge trung bình
- 2 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 62
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của docker/compose
-
Watch: exec modeCó thể đã có người làm @glours đã nhận 2 ngày trước. Đang mởkind/feature
docker/compose#14326 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/feature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] `start -p <name>` treats an optional (`required: false`) dependency as requiredCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] `mode` attribute in `configs` works but raises an unsupported warningCó thể đã có người làm @ndeloof đã nhận 6 ngày trước. Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
docker/compose#14288 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Warns about uid/gid, but with inline configs they do workCó thể đã có người làm @ndeloof đã nhận 6 ngày trước. Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
docker/compose#14283 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của docker/compose
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
praetorian-inc/augustus#334 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
TestTOMLBigFileParsesInLinearTime: a 1s wall-clock bound on a 3 MB parse fails under load (1.27s)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100