Skip to content

cli/compose/loader: don't drop tcp port when udp uses same published port#7106

Open
UditDewan wants to merge 1 commit into
docker:masterfrom
UditDewan:fix-stack-config-port-protocol-merge
Open

cli/compose/loader: don't drop tcp port when udp uses same published port#7106
UditDewan wants to merge 1 commit into
docker:masterfrom
UditDewan:fix-stack-config-port-protocol-merge

Conversation

@UditDewan

Copy link
Copy Markdown

- What I did

Fixed docker stack config / docker stack deploy silently dropping a port entry when merging multiple compose files where a service publishes the same port on both tcp and udp (e.g. 443:443 and 443:443/udp). The entry was lost even when the override file did not define any ports.

Fixes #6223

- How I did it

During merge, ports were indexed by their published port only, so the tcp and udp entries for the same published port collided and the later one overwrote the earlier one. The merge key now includes the protocol (an omitted protocol is treated as tcp, matching the long-syntax default), and the sort of the merged result uses the protocol as a tie-breaker so the output order is deterministic.

- How to verify it

# compose.yaml
services:
  web:
    image: caddy
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"

# compose.override.yaml
services:
  web:
    environment:
      FOO: bar

docker stack config -c compose.yaml -c compose.override.yaml now returns all three ports; previously the 443:443/tcp entry was missing. Regression tests added in cli/compose/loader/merge_test.go (go test ./cli/compose/loader/ -run TestLoadMultipleServicePorts).

- Human readable description for the release notes

Fix `docker stack config` dropping a port when merging compose files that publish the same port on both tcp and udp

…port

When merging multiple compose files, ports were keyed only by their
published port, so a service publishing the same port on both tcp and
udp (e.g. "443:443" and "443:443/udp") silently lost one of the two
entries during the merge, even when the override file did not define
any ports.

Include the protocol in the merge key, treating an omitted protocol as
tcp (the default for the long syntax), and make the merged order
deterministic when the same published port is used for both protocols.

Fixes docker#6223

Signed-off-by: uditDewan <udit.dewan21@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug when merging when TCP and UDP on the same published port

1 participant