spiegel_podman/pkg/specgen/generate
Paul Holzinger 19c579826a
pkg/specgen: fix port conflict on host assignment
This fixes two problems when parsing ports.

First, check for host port conflicts. When we are given the same ip:host
port combo twice then we need to reject that as invalid, the backend
cannot bind the same port twice and thus we always get a runtime
failure. Failing early in the create code path is much better.

Second, when assigning random ports for expose we still have to check
for proper conflicts. The first error was using allUsedContainerPortsMap
to check for conflicts but this holds container side ports, we need to
ensure there are no conflicts on the host port.

Then there was the other issue that the array in the map was copied and
accessed by value on lookup. And because the code did not reassign the
value it then failed to actually update the correct ports.
To address that I switch the map to store the array by reference which
will avoid the bigger copies as we only need to update the pointer now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-09 16:12:35 +02:00
..
kube specgen: move log_path handling over to the server 2026-06-03 09:22:50 +05:30
config_common.go enable gofumpt formatter 2025-11-11 12:32:46 +01:00
config_common_test.go Fix: Improve error message for empty device modes in API requests 2025-07-31 16:24:29 +00:00
config_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
config_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
config_linux_seccomp.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
config_linux_test.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container.go specgen: move log_path handling over to the server 2026-06-03 09:22:50 +05:30
container_create.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_create_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
namespaces.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
namespaces_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
namespaces_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_linux.go specgen: memoize isMqueueSupported with sync.OnceValue 2026-05-05 14:41:26 +02:00
pause_image.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_create.go fix: ensure infra image is set from infra container spec in PodConfigToSpec 2026-04-22 23:47:00 +02:00
pod_create_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
ports.go pkg/specgen: fix port conflict on host assignment 2026-06-09 16:12:35 +02:00
ports_bench_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
ports_test.go pkg/specgen: fix port conflict on host assignment 2026-06-09 16:12:35 +02:00
security_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
security_linux.go Replace strings.Split(..)[0] with strings.Cut 2026-05-22 13:08:56 -07:00
storage.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
storage_freebsd.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
storage_linux.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
validate_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
validate_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00