Commit Graph

20 Commits

Author SHA1 Message Date
Michael Crosby 43a50b0618 Refactor port allocator to not have ANY global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-03-30 17:30:59 -07:00
Antonio Murdaca 6f4d847046 Replace aliased imports of logrus, fixes #11762
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-03-26 23:22:04 +01:00
Paul Bellamy 87df5ab41b Refactor global portallocator and portmapper state
Continuation of: #11660, working on issue #11626.

Wrapped portmapper global state into a struct. Now portallocator and
portmapper have no global state (except configuration, and a default
instance).

Unfortunately, removing the global default instances will break
```api/server/server.go:1539```, and ```daemon/daemon.go:832```, which
both call the global portallocator directly. Fixing that would be a much
bigger change, so for now, have postponed that.

Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
2015-03-24 11:15:30 +00:00
Jessie Frazelle ccd4181d10 Merge pull request #11545 from cpuguy83/remove_allocator_warning
Don't warn when ip_local_port_range not found
2015-03-23 14:19:57 -07:00
Paul Bellamy 1257679876 Refactor global portallocator state into a global struct
Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
2015-03-23 20:41:41 +00:00
Brian Goff 8e4d9f3cf9 Improve err message when parsing kernel port range
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-03-23 13:29:25 -07:00
Vishnu Kannan 39d49ba7ba Reduce logging level from error to warning if "/proc/sys/net/ipv4/ip_local_port_range" proc file in not accessible.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2015-03-17 17:39:17 +00:00
Michal Minar 210ab030bc Format error by value
- Use `%v` verb to format errors.
- Give `param` constant in portallocator some better name.

Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-16 12:05:53 +01:00
Michal Minar 40d5406371 Pass buffered file reader to Fscanf instead of string reader
Unless `file` is wrapped with buffered reader, `fmt.Fscanf` will read
just one byte and terminate with `EOF`.

Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-13 09:40:53 +01:00
Michal Minar 0dcc970432 Restructured port range loader
And renamed `GetPortRange` to `PortRange`.

Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-10 10:02:43 +01:00
Michal Minar fcf8e85a35 Use default port range in unit tests
Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-09 16:58:14 +01:00
Michal Minar 0eb3544c43 Use system's ephemeral port range for port allocation
Read `/proc/sys/net/ipv4/ip_local_port_range` kernel parameter to obtain
ephemeral port range that now sets the boundaries of port allocator
which finds free host ports for those exported by containers.

Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-09 09:13:20 +01:00
shuai-z 4c97832297 fixed the way of iterating over the range of map.
Fixed the following errors:
1. Request(0) causes a dead loop when the map is full and map.last == BEGIN.
2. When map.last is the only available port (or ip), Request(0) returns ErrAllPortsAllocated (or ErrNoAvailableIPs). Exception is when map.last == BEGIN.

Signed-off-by: shuai-z <zs.broccoli@gmail.com>
2014-11-04 13:46:53 +08:00
shuai-z 2c2edabca5 added test, gofmtd
Signed-off-by: shuai-z <zs.broccoli@gmail.com>
2014-10-23 11:35:12 +08:00
shuai-z 9451cf39ef Port number 49153(BeginPortRange) would be returned twice, causing duplication and potential errors.
If we first request port 49153 (BeginPortRange) explicitly, and later some time request the next free port (of same ip/proto) by calling RequestPort() with port number 0, we will again get 49153 returned, even if it's currently in use. Because findPort() blindly retured BeginPortRange the first run, without checking if it has already been taken.

Signed-off-by: shuai-z <zs.broccoli@gmail.com>
2014-10-23 10:49:33 +08:00
LK4D4 f387cc1205 Refactoring portallocator
Faster, more documented, less code.
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-07-01 21:59:11 +04:00
Erik Hollensbe e77729c2e0 Use last allocated port logic in port allocator
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-06-27 10:51:26 -07:00
Erik Hollensbe ffd68badc0 Make ErrPortAlreadyAllocated an error interface with a few extras,
adjust tests to fit.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-06-27 10:51:25 -07:00
Erik Hollensbe f0489ce3a9 portallocator: rewrite to simplify, removes race condition
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-05-21 09:14:53 -07:00
Alexander Larsson 359b7df5d2 Rename runtime/* to daemon/*
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-17 14:43:01 -07:00