On Podman, detect if application is listening on the loopback interface, and either error out or not depending on --ignore-localhost#6620
Conversation
|
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
fc47c36 to
47a6943
Compare
47a6943 to
965d5f5
Compare
--ignore-localhost is passed
--ignore-localhost is passed--ignore-localhost
Specifically, this will be useful in Podman to detect applications that are bound to the loopback interface
…und to the loopback interface (on any ports supposed to be forwarded) Next step will be to provide an option for end-users to override this behavior, by either: - ignoring this error (--ignore-localhost); - or explicitly adding a redirect via a side container (--forward-localhost) More context in redhat-developer#6510 (comment)
Currently, `odo dev` on Podman will error out if it detects that the application is listening on the container loopback interface. Instead of erroring out, this flag allows users to ignore such failure; a warning will be displayed anyway if the application is listening on the container loopback interface, but odo will not error out. Ports will be marked as forwarded, but Podman might fail to redirect traffic to the application if it is bound to this loopback interface.
- odo describe component - odo dev --debug Some projects used there are listening to the loopback interface, so they won't work on Podman unless --ignore-localhost is passed. Next, we'll pass --forward-localhost when it is implemented, so we can have a fully working project with port-forwarding.
af76f69 to
d60d931
Compare
--ignore-localhost--ignore-localhost
Requested in review
Flaky E2E test - reported in #6582 /override windows-integration-test/Windows-test |
|
@rm3l: Overrode contexts on behalf of rm3l: windows-integration-test/Windows-test DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
Kudos, SonarCloud Quality Gate passed!
|
…ce, and either error out or not depending on `--ignore-localhost` (redhat-developer#6620) * Add functions allowing to detect ports opened in a given container Specifically, this will be useful in Podman to detect applications that are bound to the loopback interface * Make `odo dev` fail on Podman if we detect that the application is bound to the loopback interface (on any ports supposed to be forwarded) Next step will be to provide an option for end-users to override this behavior, by either: - ignoring this error (--ignore-localhost); - or explicitly adding a redirect via a side container (--forward-localhost) More context in redhat-developer#6510 (comment) * Add '--ignore-localhost' flag to 'odo dev' on Podman Currently, `odo dev` on Podman will error out if it detects that the application is listening on the container loopback interface. Instead of erroring out, this flag allows users to ignore such failure; a warning will be displayed anyway if the application is listening on the container loopback interface, but odo will not error out. Ports will be marked as forwarded, but Podman might fail to redirect traffic to the application if it is bound to this loopback interface. * Add test cases * Fix existing integration tests by passing --ignore-localhost on Podman - odo describe component - odo dev --debug Some projects used there are listening to the loopback interface, so they won't work on Podman unless --ignore-localhost is passed. Next, we'll pass --forward-localhost when it is implemented, so we can have a fully working project with port-forwarding. * Extract logic for handling loopback ports in a separate method Requested in review








What type of PR is this:
/kind feature
/area dev
/area odo-on-podman
What does this PR do / why we need it:
The way
odocurrently does port-forwarding on Podman is via aHostPortin the relevant container in the pod spec. But as reported in #6510 and containers/podman#17353, Podman won't forward traffic to the container if the container port is bound to the container loopback interface.As discussed in #6510 (comment) (and similar to how things work on DevSpaces), this PR tries to detect if ports that need to be forwarded are bound to the container loopback interface. If this is the case:
odo devon Podman will error out with an error message indicating the issue, along with a recommendation to either change the application to listen on 0.0.0.0, or to runodo devwith--forward-localhost(PR to follow up soon).odo devis run with--ignore-localhost, this message will be displayed as a warning, but this won't preventodo devfrom running. However, any request sent out to the local port forwarded to the container on its loopback interface might not work with Podman.I'll create a subsequent PR that adds a new
--forward-localhostflag, the goal of which is to make port-forwarding work in such cases via a side container. It'll be inspired by what had been done in #6589Which issue(s) this PR fixes:
This relates to #6510
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
This behavior should not affect the default cluster mode.
To test the changes on Podman, either use a project with an application listening on some port on localhost, or leverage some existing stacks like Node.JS which have debuggers listening on localhost.
--ignore-localhost,odo devon Podman should start but error out after detecting that the port is bound to the container loopback interface:NOTE: only ports that are expected to be forwarded are checked. In the example above, if I run
ODO_EXPERIMENTAL_MODE=t odo dev --platform=podman(without--debug),odo devshould start and work normally.--ignore-localhost,odo devon Podman should start but display a warning message after detecting that the port is bound to the container loopback interface: