Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Epic: Move service selection into the backend API instead of pre-filtering the project in the CLI

オープン
#14,346 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
docker-compose, go
領域
api, backend

調査の方向性

This is a design epic, not a task to pick up. Start by reading how WithSelectedServices is applied in cmd/compose/up.go and cmd/compose/scale.go, then the reconciler's servicesUsingNetwork and servicesUsingVolume helpers. Done means maintainers agree on the ServiceSelection shape and the open questions in the issue are resolved; implementation work would follow in separate issues.

索引モデルが issue の本文から書いたものです。

説明

"This issue was filed by an AI agent on a human's behalf. The human submitter may not have independently verified the report."

Summary

Service selection (up web, --no-deps, watch rebuilds, …) is currently applied by the callers of the backend, by pre-filtering the types.Project with WithSelectedServices. This issue proposes making the selection an explicit input of the backend API, so that the reconciler sees the whole model and decides what the selection means. It also matters for other consumers of pkg/api (library users, Docker Desktop, …): they should not have to reproduce the CLI's pre-filtering to get correct behavior.

Related: #14081 (converging the start phase into the plan engine), #14291.

Problem

Two different notions of "selection" coexist today:

  1. Services in the API options (CreateOptions.Services, …) means targeted services. The reconciler still converges every other service, with the RecreateDependencies policy (reconcileService).
  2. Pre-filtering the project (project.WithSelectedServices(...), done in cmd/compose/up.go and cmd/compose/scale.go for --no-deps, and in watch's rebuild) means the other services do not exist: they are moved to DisabledServices, and DependsOn of the kept services is pruned to the selection.

Because the reconciler receives a truncated model without knowing it, it makes wrong inferences. Concretely, it looks for the consumers of a network or volume in project.Services only (servicesUsingNetwork, servicesUsingVolume). With a narrowed project, a drifted network or volume that is also used by a service outside the selection looks unused by it:

  • the plan stops/disconnects (or removes) only the selected services' containers, then tries to remove the network/volume, which fails with "in use";
  • for a volume, the user is first asked to confirm a data-destroying recreation that cannot succeed.

I reproduced this at the reconciler level with unit tests, on a project narrowed to one service whose network (or volume) is shared with a disabled service that has a live container. up --no-deps <svc> and scale --no-deps build exactly such a project, so I expect the same exposure there; I have not reproduced it end to end against a daemon. Dependency pruning in WithSelectedServices may also affect config hashes; I have not checked that.

A narrow guard in the reconciler (leave a drifted resource alone, with a warning, while a disabled service's live container still holds it) is being added to #14291 for the watch rebuild. It is a mitigation: it works around the truncated model rather than removing the cause.

Proposal

Keep the full project as the model and pass the selection to the backend as data. A sketch, open for discussion:

// ServiceSelection scopes an operation to part of the project.
type ServiceSelection struct {
	Services     []string
	Dependencies DependencyScope // include (default), ignore (--no-deps), dependents (watch rebuild)
}

carried by the options of the operations that converge or start containers (CreateOptions, UpOptions/StartOptions, ScaleOptions, WatchOptions), and applied at a single point, in the plan preparation, once the canonical project has been built.

Semantics the reconciler would own:

  • The model stays whole: every consumer of a network or volume is visible, and the dependency graph is the real one.
  • The selection bounds which services' containers may be created, recreated, started, stopped or waited on.
  • Infrastructure needed by the selected services is created if missing. A drifted network or volume is recreated only if all its consumers are within the selection; otherwise it is kept, with a warning.
  • Orphan detection is unaffected by the selection.

Compatibility

  • Additive: a caller that keeps pre-filtering the project still works, since it just yields a project with fewer services.
  • The existing Services fields keep their current meaning ("targets"); the new field must not silently redefine them.
  • Commands that never go through the plan (config, pull, push, run's own container) can keep pre-filtering client side. Migration can go command by command, starting with up, create, start, scale and watch.

Questions

  • Is a single ServiceSelection value the right shape, or should the dependency scope stay a separate option?
  • Should RecreateDependencies be folded into the selection, since it exists to express "what happens to services outside the targets"?
  • Are there library consumers relying on the current pre-filtering contract that this would break?

Feedback from anyone consuming pkg/api is welcome.

主要言語
Go
スター
38.4k
フォーク
5.9k
平均マージ
2日 4時間
マージ済み PR(30日)
70

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

docker/compose のほかの issue

docker/compose の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。