refactor(reconcile): use Project.AllServices instead of a local copy
Some checks are pending
ci / validate (lint) (push) Waiting to run
ci / validate (relay-lint) (push) Waiting to run
ci / validate (relay-test) (push) Waiting to run
ci / validate (validate-docs) (push) Waiting to run
ci / validate (validate-go-mod) (push) Waiting to run
ci / validate (validate-headers) (push) Waiting to run
ci / validate (validate-mocks) (push) Waiting to run
ci / binary (push) Waiting to run
ci / binary-finalize (push) Blocked by required conditions
ci / bin-image-test (push) Waiting to run
ci / relay-image-test (push) Waiting to run
ci / test (push) Waiting to run
ci / e2e (plugin, oldstable, graphdriver) (push) Waiting to run
ci / e2e (standalone, oldstable, graphdriver) (push) Waiting to run
ci / e2e (plugin, stable, containerd) (push) Waiting to run
ci / e2e (plugin, stable, graphdriver) (push) Waiting to run
ci / e2e (standalone, stable, containerd) (push) Waiting to run
ci / e2e (standalone, stable, graphdriver) (push) Waiting to run
ci / coverage (push) Blocked by required conditions
ci / ci-ok (push) Blocked by required conditions
ci / release (push) Blocked by required conditions
docs-upstream / docs-yaml (push) Waiting to run
docs-upstream / validate (push) Blocked by required conditions
merge / bin-image-prepare (push) Waiting to run
merge / bin-image (push) Blocked by required conditions
merge / relay-image (push) Waiting to run
merge / module-image (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
zizmor / zizmor (push) Waiting to run

declaredServices duplicated (*types.Project).AllServices(), already in
the pinned compose-go: Services plus DisabledServices in a fresh map.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2026-10-15 16:08:48 +02:00 • committed by Nicolas De loof
parent d399476aab
commit 7b36d08dd0

View file

@ -20,7 +20,6 @@ import (
"cmp"
"context"
"fmt"
"maps"
"slices"
"sort"
"strings"
@ -290,7 +289,7 @@ func (r *reconciler) reconcileNetworks() error {
// a same-name divergence does, and can't while a container the plan
// doesn't manage is still attached.
if observed.Name == desired.Name {
if held := r.heldOutsideSelection(networkConsumers(r.declaredServices(), key)); len(held) > 0 {
if held := r.heldOutsideSelection(networkConsumers(r.project.AllServices(), key)); len(held) > 0 {
logrus.Warnf("network %q config has changed but it is still used by %s, outside the current service selection: not recreated. "+
"Run the command on the whole project to apply the change", desired.Name, strings.Join(held, ", "))
continue
@ -464,7 +463,7 @@ func (r *reconciler) reconcileVolumes() error {
}
// Removing the volume requires removing every container referencing
// it first: don't ask to destroy its data when the plan can't.
if held := r.heldOutsideSelection(volumeConsumers(r.declaredServices(), key)); len(held) > 0 {
if held := r.heldOutsideSelection(volumeConsumers(r.project.AllServices(), key)); len(held) > 0 {
logrus.Warnf("volume %q config has changed but it is still used by %s, outside the current service selection: not recreated. "+
"Run the command on the whole project to apply the change", desired.Name, strings.Join(held, ", "))
continue
@ -611,16 +610,6 @@ func networkConsumers(services types.Services, networkKey string) []string {
return names
}
// declaredServices returns every service of the model, selected or not:
// project.Services plus the DisabledServices a selection (or an inactive
// profile) moved aside.
func (r *reconciler) declaredServices() types.Services {
all := make(types.Services, len(r.project.Services)+len(r.project.DisabledServices))
maps.Copy(all, r.project.DisabledServices)
maps.Copy(all, r.project.Services)
return all
}
// heldOutsideSelection filters the given consumers of a network or volume down
// to those the plan doesn't manage (DisabledServices) yet still have a live
// container: they keep the resource in use, and the plan neither detaches nor