Skip to content

Exposed ports are only included when not --net=host#24164

Merged
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
mheon:host_network_no_expose_in_ports
Oct 4, 2024
Merged

Exposed ports are only included when not --net=host#24164
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
mheon:host_network_no_expose_in_ports

Conversation

@mheon
Copy link
Copy Markdown
Member

@mheon mheon commented Oct 4, 2024

Undoing some of my own work here from #24090 now that we have the ExposedPorts field implemented in inspect. I considered a revert of that patch, but it's still needed as without it we'd be including exposed ports when --net=container which is not correct.

Basically, exposed ports for a container should always go in the new ExposedPorts field we added. They sometimes go in the Ports field in NetworkSettings, but only when the container is not net=host and not net=container. We were always including exposed ports, which was not correct, but is an easy logical fix.

Also required is a test change to correct the expected behavior as we were testing for incorrect behavior.

Fixes https://issues.redhat.com/browse/RHEL-60382

Does this PR introduce a user-facing change?

NONE

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 4, 2024
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@baude
Copy link
Copy Markdown
Member

baude commented Oct 4, 2024

code lgtm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

but personally I would have a slight preference for if c.config.NetNsCtr == "" && c.NetworkMode() != "host" as I think this is clearer but it should be logically the same

@mheon mheon force-pushed the host_network_no_expose_in_ports branch 2 times, most recently from bb2c24c to 5fed0ae Compare October 4, 2024 14:08
@packit-as-a-service
Copy link
Copy Markdown

Cockpit tests failed for commit bb2c24c212a53fabd841c8e06838a22842f6b329. @martinpitt, @jelly, @mvollmer please check.

Undoing some of my own work here from containers#24090 now that we have the
ExposedPorts field implemented in inspect. I considered a revert
of that patch, but it's still needed as without it we'd be
including exposed ports when --net=container which is not
correct.

Basically, exposed ports for a container should always go in the
new ExposedPorts field we added. They sometimes go in the Ports
field in NetworkSettings, but only when the container is not
net=host and not net=container. We were always including exposed
ports, which was not correct, but is an easy logical fix.

Also required is a test change to correct the expected behavior
as we were testing for incorrect behavior.

Fixes https://issues.redhat.com/browse/RHEL-60382

Signed-off-by: Matt Heon <mheon@redhat.com>
@mheon mheon force-pushed the host_network_no_expose_in_ports branch from 5fed0ae to 8061553 Compare October 4, 2024 15:19
@mheon
Copy link
Copy Markdown
Member Author

mheon commented Oct 4, 2024

Tests green

Copy link
Copy Markdown
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 4, 2024
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Oct 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit d28af23 into containers:main Oct 4, 2024
TomSweeneyRedHat added a commit to TomSweeneyRedHat/podman that referenced this pull request Oct 28, 2024
This fixes an exposed ports issue in RHEL 4.9-rhel for RHEL 9.5.

This includes the fixes from the following PRs:

First PR: containers#24090
Second PR: containers#24110
Third PR: containers#24164

With an additional tweak from @Luap99 in containers#24333
regarding the looping in libpod/container_inspect.go.

This changes is needed in the 5.2-rhel branch to assure successful
upgrades as the same patches have been used for the following issues
in the Podman v4.9-rhel branch

Fixes: https://issues.redhat.com/browse/ACCELFIX-299
Fixes: https://issues.redhat.com/browse/ACCELFIX-300

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jan 3, 2025
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants