Skip to content

Revert "Added API to set ephemeral port allocator range."#43066

Merged
thaJeztah merged 2 commits into
moby:masterfrom
akerouanton:fix-43054
Jun 3, 2022
Merged

Revert "Added API to set ephemeral port allocator range."#43066
thaJeztah merged 2 commits into
moby:masterfrom
akerouanton:fix-43054

Conversation

@akerouanton

@akerouanton akerouanton commented Dec 6, 2021

Copy link
Copy Markdown
Member

- What I did

Since commit 2c4a868, Docker doesn't
use the value of net.ipv4.ip_local_port_range when choosing an ephemeral
port. This change reverts back to the previous behavior.

Fixes #43054.

- How to verify it

  1. make shell
  2. In the container, sysctl -w net.ipv4.ip_local_port_range="39000 40000"
  3. Start dockerd
  4. Run docker run --rm -it -p 80 nginx
  5. Check what port Docker has picked with docker ps

- Description for the changelog

Use the value of net.ipv4.ip_local_port_range when choosing an ephemeral port

@neersighted neersighted left a comment

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.

This looks really clean from a revert/application standpoint. However, I do wonder if it is desirable to reintroduce the ability to set the range over the API in a way that is documented and falls back to the kernel parameter as a default?

Regardless, this is aligned with the documented behavior and the right move given this has manifested as a regression for users.

@tianon tianon left a comment

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.

I was worried that the removal of OptionDynamicPortRange would be a problem, but it looks like it was only ever used in #40055 (which is still unmerged). 👍

@tianon

tianon commented Jun 2, 2022

Copy link
Copy Markdown
Member

(This needs a rebase for some conflicts, but they look like they're pretty minor -- just the imports, perhaps?)

akerouanton and others added 2 commits June 2, 2022 22:56
Since commit 2c4a868, Docker doesn't
use the value of net.ipv4.ip_local_port_range when choosing an ephemeral
port. This change reverts back to the previous behavior.

Fixes moby#43054.

Signed-off-by: Albin Kerouanton <[email protected]>
logrus.WithError(err).Infof("falling back to default port range %d-%d", defaultPortRangeStart, defaultPortRangeEnd)
start, end = defaultPortRangeStart, defaultPortRangeEnd
logrus.WithError(err).Infof("falling back to default port range %d-%d", DefaultPortRangeStart, DefaultPortRangeEnd)
start, end = DefaultPortRangeStart, DefaultPortRangeEnd

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.

Looks like these consts aren't used outside of the package, so I guess we can keep those

@thaJeztah

Copy link
Copy Markdown
Member

Doing a quick rebase, and I'll add a commit to keep the consts un-exported

@thaJeztah thaJeztah left a comment

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.

LGTM

@akerouanton

Copy link
Copy Markdown
Member Author

Ah, sorry @thaJeztah, didn't had time to rebase it today. Thanks for doing it 🙂

@thaJeztah

Copy link
Copy Markdown
Member

No worries! (apologies on our side for this have taken so long!)

// consistent with default /proc/sys/net/ipv4/ip_local_port_range
// upper bound on linux
defaultPortRangeEnd = 60999
defaultPortRangeEnd = 65535

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.

Let me comment on this line; this may have been related to #40055 (comment) as well (in case we need to un-revert this change in range)

/cc @neersighted @corhere @evol262

(and myself, for if this causes havoc in our products 🙈)

@thaJeztah

Copy link
Copy Markdown
Member

Failure is unrelated; known flaky test (#38521)

=== FAIL: github.com/docker/docker/integration-cli TestDockerSuite/TestStartReturnCorrectExitCode (4.54s)
    docker_cli_start_test.go:191: assertion failed: 
        Command:  D:\a\moby\moby\out\docker.exe start -a withRestart
        ExitCode: 0
        Stdout:   
        Stderr:   
        
        Failures:
        ExitCode was 0 expected 11
    --- FAIL: TestDockerSuite/TestStartReturnCorrectExitCode (4.54s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux kernel ephemeral port range ignored in Docker 20+

4 participants