Skip to content

Commit 12f1415

Browse files
fix: re-deploy docker proxy in case of change in placement constraint (#828) (#829)
(cherry picked from commit 51a5bc1) Co-authored-by: Tanmoy Sarkar <57363826+tanmoysrt@users.noreply.github.com>
1 parent e7d8f9f commit 12f1415

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

container_manager/docker_proxy.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,28 @@ func (m Manager) CreateDockerProxy(serviceName string, placementConstraints []st
6868
fmt.Sprintf("VOLUMES_WRITE=%d", boolToInt(config.Permission.Volumes == DockerProxyReadWritePermission)),
6969
}
7070

71-
// Currently, there will be only changes to the environment variables, so those wil be checked for changes
71+
// Currently, there will be only changes to the environment variables and placement constraints,so those wil be checked for changes
7272
isUpdate := false
7373
existingService, _, err := m.client.ServiceInspectWithRaw(m.ctx, serviceName, types.ServiceInspectOptions{})
7474
if err == nil {
7575
if existingService.Spec.TaskTemplate.ContainerSpec != nil {
7676
envVars := existingService.Spec.TaskTemplate.ContainerSpec.Env
7777
// if env vars are the same, do not update
78-
if isSameList(envVars, environmentVariables) {
79-
return nil
80-
} else {
78+
if !isSameList(envVars, environmentVariables) {
8179
isUpdate = true
8280
}
8381
}
82+
if existingService.Spec.TaskTemplate.Placement != nil {
83+
constraints := existingService.Spec.TaskTemplate.Placement.Constraints
84+
// if constraints are the same, do not update
85+
if !isSameList(constraints, placementConstraints) {
86+
isUpdate = true
87+
}
88+
}
89+
}
90+
91+
if !isUpdate {
92+
return nil
8493
}
8594

8695
serviceSpec := swarm.ServiceSpec{

0 commit comments

Comments
 (0)