Use the calculated port when useBindPortIP is enabled
This commit is contained in:
parent
9544dece07
commit
f84d947115
2 changed files with 73 additions and 23 deletions
|
@ -150,10 +150,12 @@ func (p *Provider) addServerTCP(ctx context.Context, container dockerData, loadB
|
|||
return errors.New("load-balancer is not defined")
|
||||
}
|
||||
|
||||
serverPort := ""
|
||||
var serverPort string
|
||||
if len(loadBalancer.Servers) > 0 {
|
||||
serverPort = loadBalancer.Servers[0].Port
|
||||
loadBalancer.Servers[0].Port = ""
|
||||
}
|
||||
|
||||
ip, port, err := p.getIPPort(ctx, container, serverPort)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -165,11 +167,6 @@ func (p *Provider) addServerTCP(ctx context.Context, container dockerData, loadB
|
|||
loadBalancer.Servers = []dynamic.TCPServer{server}
|
||||
}
|
||||
|
||||
if serverPort != "" {
|
||||
port = serverPort
|
||||
loadBalancer.Servers[0].Port = ""
|
||||
}
|
||||
|
||||
if port == "" {
|
||||
return errors.New("port is missing")
|
||||
}
|
||||
|
@ -183,7 +180,12 @@ func (p *Provider) addServer(ctx context.Context, container dockerData, loadBala
|
|||
return errors.New("load-balancer is not defined")
|
||||
}
|
||||
|
||||
serverPort := getLBServerPort(loadBalancer)
|
||||
var serverPort string
|
||||
if len(loadBalancer.Servers) > 0 {
|
||||
serverPort = loadBalancer.Servers[0].Port
|
||||
loadBalancer.Servers[0].Port = ""
|
||||
}
|
||||
|
||||
ip, port, err := p.getIPPort(ctx, container, serverPort)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -196,11 +198,6 @@ func (p *Provider) addServer(ctx context.Context, container dockerData, loadBala
|
|||
loadBalancer.Servers = []dynamic.Server{server}
|
||||
}
|
||||
|
||||
if serverPort != "" {
|
||||
port = serverPort
|
||||
loadBalancer.Servers[0].Port = ""
|
||||
}
|
||||
|
||||
if port == "" {
|
||||
return errors.New("port is missing")
|
||||
}
|
||||
|
@ -302,13 +299,6 @@ func (p *Provider) getPortBinding(container dockerData, serverPort string) (*nat
|
|||
return nil, fmt.Errorf("unable to find the external IP:Port for the container %q", container.Name)
|
||||
}
|
||||
|
||||
func getLBServerPort(loadBalancer *dynamic.ServersLoadBalancer) string {
|
||||
if loadBalancer != nil && len(loadBalancer.Servers) > 0 {
|
||||
return loadBalancer.Servers[0].Port
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getPort(container dockerData, serverPort string) string {
|
||||
if len(serverPort) > 0 {
|
||||
return serverPort
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue