mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Initialize portMapper in RequestPort too
Api requesting port for daemon before init_networkdriver called. Problem is that now initialization of api depends on initialization of daemon and their intializations runs in parallel. Proper fix will be just do it sequentially. For now I don't want refactor it, because it can bring additional problems in 1.6.0. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
ddbc68f564
commit
584180fce7
1 changed files with 9 additions and 1 deletions
|
@ -78,12 +78,19 @@ var (
|
||||||
bridgeIPv6Addr net.IP
|
bridgeIPv6Addr net.IP
|
||||||
globalIPv6Network *net.IPNet
|
globalIPv6Network *net.IPNet
|
||||||
portMapper *portmapper.PortMapper
|
portMapper *portmapper.PortMapper
|
||||||
|
once sync.Once
|
||||||
|
|
||||||
defaultBindingIP = net.ParseIP("0.0.0.0")
|
defaultBindingIP = net.ParseIP("0.0.0.0")
|
||||||
currentInterfaces = ifaces{c: make(map[string]*networkInterface)}
|
currentInterfaces = ifaces{c: make(map[string]*networkInterface)}
|
||||||
ipAllocator = ipallocator.New()
|
ipAllocator = ipallocator.New()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initPortMapper() {
|
||||||
|
once.Do(func() {
|
||||||
|
portMapper = portmapper.New()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func InitDriver(job *engine.Job) error {
|
func InitDriver(job *engine.Job) error {
|
||||||
var (
|
var (
|
||||||
networkv4 *net.IPNet
|
networkv4 *net.IPNet
|
||||||
|
@ -100,7 +107,7 @@ func InitDriver(job *engine.Job) error {
|
||||||
fixedCIDR = job.Getenv("FixedCIDR")
|
fixedCIDR = job.Getenv("FixedCIDR")
|
||||||
fixedCIDRv6 = job.Getenv("FixedCIDRv6")
|
fixedCIDRv6 = job.Getenv("FixedCIDRv6")
|
||||||
)
|
)
|
||||||
portMapper = portmapper.New()
|
initPortMapper()
|
||||||
|
|
||||||
if defaultIP := job.Getenv("DefaultBindingIP"); defaultIP != "" {
|
if defaultIP := job.Getenv("DefaultBindingIP"); defaultIP != "" {
|
||||||
defaultBindingIP = net.ParseIP(defaultIP)
|
defaultBindingIP = net.ParseIP(defaultIP)
|
||||||
|
@ -353,6 +360,7 @@ func setupIPTables(addr net.Addr, icc, ipmasq bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RequestPort(ip net.IP, proto string, port int) (int, error) {
|
func RequestPort(ip net.IP, proto string, port int) (int, error) {
|
||||||
|
initPortMapper()
|
||||||
return portMapper.Allocator.RequestPort(ip, proto, port)
|
return portMapper.Allocator.RequestPort(ip, proto, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue