fix(reconcile): preserve zero-replica services during hashing

Signed-off-by: Junhao Liao <[email protected]>
This commit is contained in:
Junhao Liao
2026-07-16 15:19:50 +02:00
committed by Guillaume Lours
parent 2849ded809
commit 536d8f331d
2 changed files with 28 additions and 1 deletions
+25
View File
@@ -242,6 +242,31 @@ func TestWaitDependencies(t *testing.T) {
}
assert.NilError(t, tested.(*composeService).waitDependencies(t.Context(), &project, "", dependencies, nil, 0))
})
t.Run("should skip zero-replica dependencies after service hashing", func(t *testing.T) {
replicas := 0
project := types.Project{Name: strings.ToLower(testProject), Services: types.Services{
"app": {
Name: "app",
DependsOn: types.DependsOnConfig{
"disabled": {
Condition: ServiceConditionRunningOrHealthy,
Required: true,
},
},
},
"disabled": {
Name: "disabled",
Deploy: &types.DeployConfig{Replicas: &replicas},
},
}}
_, err := ServiceHash(project.Services["disabled"])
assert.NilError(t, err)
assert.NilError(t, tested.(*composeService).waitDependencies(
t.Context(), &project, "app", project.Services["app"].DependsOn, nil, 0,
))
})
t.Run("should skip dependencies with condition service_started", func(t *testing.T) {
dbService := types.ServiceConfig{Name: "db", Scale: intPtr(1)}
redisService := types.ServiceConfig{Name: "redis", Scale: intPtr(1)}
+3 -1
View File
@@ -30,7 +30,9 @@ func ServiceHash(o types.ServiceConfig) (string, error) {
o.PullPolicy = ""
o.Scale = nil
if o.Deploy != nil {
o.Deploy.Replicas = nil
deploy := *o.Deploy
deploy.Replicas = nil
o.Deploy = &deploy
}
o.DependsOn = nil
o.Profiles = nil