Commit Graph

20 Commits

Author SHA1 Message Date
163fcc5bfd Refactor port allocator to not have ANY global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 43a50b06187e324e43b26003cace0f351a5fb78c
Component: engine
2015-03-30 17:30:59 -07:00
e5b36a723c Replace aliased imports of logrus, fixes #11762
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 6f4d847046cb4e072de61d042c0266190d73a8c9
Component: engine
2015-03-26 23:22:04 +01:00
8938696741 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>
Upstream-commit: 87df5ab41b3f9b2bdd8682f4afd41dac78f7e96d
Component: engine
2015-03-24 11:15:30 +00:00
6be1b45eff Merge pull request #11545 from cpuguy83/remove_allocator_warning
Don't warn when ip_local_port_range not found
Upstream-commit: ccd4181d10752c41603fcc03bb6b576603b24271
Component: engine
2015-03-23 14:19:57 -07:00
4df1193b38 Refactor global portallocator state into a global struct
Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
Upstream-commit: 12576798769081823a3f660b46290da808630616
Component: engine
2015-03-23 20:41:41 +00:00
f2b00f6fe1 Improve err message when parsing kernel port range
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 8e4d9f3cf9669f45b0591eea27c47b6f64d89c2d
Component: engine
2015-03-23 13:29:25 -07:00
8da4d5374d 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)
Upstream-commit: 39d49ba7ba21f204f5fc174aaf319ed1cdad790f
Component: engine
2015-03-17 17:39:17 +00:00
c29e43cc4b 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>
Upstream-commit: 210ab030bc3dab7bcf8f7252f2f9facb5a26cb6b
Component: engine
2015-03-16 12:05:53 +01:00
dc9421e6d9 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>
Upstream-commit: 40d540637168fd5781e0c4a9cbd91959b7407d96
Component: engine
2015-03-13 09:40:53 +01:00
70fb9fcc59 Restructured port range loader
And renamed `GetPortRange` to `PortRange`.

Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: 0dcc970432677ddd13d8ed583de84ae075888228
Component: engine
2015-03-10 10:02:43 +01:00
c40472feb0 Use default port range in unit tests
Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: fcf8e85a35cddfd1f75f652a513015bb6f169257
Component: engine
2015-03-09 16:58:14 +01:00
054ec22a23 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>
Upstream-commit: 0eb3544c43cb8e9488d6bf329ceecc11fa0db6f1
Component: engine
2015-03-09 09:13:20 +01:00
47d12f79de 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>
Upstream-commit: 4c978322979f00408c72b50931a8cdea2d5cdefc
Component: engine
2014-11-04 13:46:53 +08:00
b91a2b389f added test, gofmtd
Signed-off-by: shuai-z <zs.broccoli@gmail.com>
Upstream-commit: 2c2edabca5471fa969358cb98619f277d585e76c
Component: engine
2014-10-23 11:35:12 +08:00
79574eea31 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>
Upstream-commit: 9451cf39eff037eccb04319c1e601d08495cab3c
Component: engine
2014-10-23 10:49:33 +08:00
e3c0c2772d Refactoring portallocator
Faster, more documented, less code.
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
Upstream-commit: f387cc1205b79ffbe30b28f5df13da034d8221fd
Component: engine
2014-07-01 21:59:11 +04:00
4ad46ffe31 Use last allocated port logic in port allocator
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Upstream-commit: e77729c2e081c5ce55aa1d4f316b7c7703e5de96
Component: engine
2014-06-27 10:51:26 -07:00
52ddc2736f 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)
Upstream-commit: ffd68badc0a3d70fbd063903702355a387621b10
Component: engine
2014-06-27 10:51:25 -07:00
ff6d32db91 portallocator: rewrite to simplify, removes race condition
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Upstream-commit: f0489ce3a9a4023265bbbd5e9cb333e95f950088
Component: engine
2014-05-21 09:14:53 -07:00
f7be50364d Rename runtime/* to daemon/*
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 359b7df5d2af5733b8a1ea6746d062053053b23e
Component: engine
2014-04-17 14:43:01 -07:00