mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
fix(reconcile): preserve zero-replica services during hashing
Signed-off-by: Junhao Liao <[email protected]>
This commit is contained in:
committed by
Guillaume Lours
parent
2849ded809
commit
536d8f331d
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user