Re: [jgroups-users] How to find a valid bind address in docker

Questions/problems related to using JGroups <[email protected]> Tue, 8 Nov 2016 15:48:51 +0100
Newsgroups gmane.comp.java.javagroups.general
Message-ID <[email protected]>
Hi Staffan,

On 08/11/16 14:06, Questions/problems related to using JGroups wrote:
> HI,
>
> My attempts to accept TCPPING or any other connections from non-local
> peers are blocked by org.jgroups.util.Util.checkIfValidAddress. See
> stack trace below.
>
> My easiest way out would be to bind to 0.0.0.0 but register a logical IP
> address as the external bind address. Can that be done?


While WildFly can bind to the wildcard address, JGroups can't. It 
requires the IP address of a valid local network interface. Why don't 
you set system property -Djboss.bind.address.private=BIND_ADDR?

You could use symbolic names for BIND_ADDR, e.g. 
match-address=192.168.1.\* or match-interface=eth2. Consult the manual 
for more options.

> Background: I'm trying to run Keycloak 2.3.0 in Kubernetes. Each
> instance will have its own Service, and the service gets an IP address
> that is not the same as that returned by `hostname -i`.

Can't you use KUBE_PING for discovery protocol, instead of TCPPING? It 
was written specifically for Kubernetes. TCPPING will work, too, but 
there's more configuration work to be done to make it work.

> For example I have a resolvable name keycloak-0 with an IP found in env var
> KEYCLOAK_0_SERVICE_HOST. I can't bind to that address, but I want to use
> it for initial_hosts.

Why can't you use it as BIND_ADDR (see above)?

> Can I somehow configure the socket-binding entries with 0.0.0.0 but pass
> ${env.KEYCLOAK_0_SERVICE_HOST} as bind_addr to JGroups? The source for
> checkIfValidAddress indicates that only local addresses are valid.
>
> regards
> Staffan Olsson
>
> 12:17:32,979 INFO  [org.jboss.as.server.deployment] (MSC service thread
> 1-3) WFLYSRV0027: Starting deployment of "keycloak-server.war"
> (runtime-name: "keycloak-server.war")
> 12:17:33,427 WARN  [org.jboss.as.clustering.jgroups] (MSC service thread
> 1-1) WFLYCLJG0006: property bind_addr for protocol
> org.jgroups.protocols.TCP attempting to override socket binding value
> 0.0.0.0 : property value 10.0.0.170 will be ignored
> 12:17:33,582 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1)
> MSC000001: Failed to start service jboss.jgroups.channel.ee
> <http://jboss.jgroups.channel.ee>: org.jboss.msc.service.StartException
> in service jboss.jgroups.channel.ee <http://jboss.jgroups.channel.ee>:
> java.security.PrivilegedActionException: java.net.BindException: [TCP]
> /0.0.0.0 <http://0.0.0.0> is not a valid address on any local network
> interface
>     at
> org.wildfly.clustering.jgroups.spi.service.ChannelBuilder.start(ChannelBuilder.java:80)
>     at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
>     at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>     at java.lang.Thread.run(Thread.java:745)
> Caused by: java.security.PrivilegedActionException:
> java.net.BindException: [TCP] /0.0.0.0 <http://0.0.0.0> is not a valid
> address on any local network interface
>     at
> org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)
>     at
> org.jboss.as.clustering.jgroups.JChannelFactory.createChannel(JChannelFactory.java:98)
>     at
> org.wildfly.clustering.jgroups.spi.service.ChannelBuilder.start(ChannelBuilder.java:78)
>     ... 5 more
> Caused by: java.net.BindException: [TCP] /0.0.0.0 <http://0.0.0.0> is
> not a valid address on any local network interface
>     at org.jgroups.util.Util.checkIfValidAddress(Util.java:3522)
>     at
> org.jgroups.stack.Configurator.ensureValidBindAddresses(Configurator.java:903)
>     at
> org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:118)
>     at
> org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:57)
>     at org.jgroups.stack.ProtocolStack.setup(ProtocolStack.java:477)
>     at org.jgroups.JChannel.init(JChannel.java:853)
>     at org.jgroups.JChannel.<init>(JChannel.java:159)
>     at
> org.jboss.as.clustering.jgroups.JChannelFactory$1.run(JChannelFactory.java:95)
>     at
> org.jboss.as.clustering.jgroups.JChannelFactory$1.run(JChannelFactory.java:92)
>     at
> org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636)
>     ... 7 more
>
> 12:17:33,595 ERROR [org.jboss.as.controller.management-operation]
> (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
>     ("subsystem" => "jgroups"),
>     ("channel" => "ee")
> ]) - failure description: {"WFLYCTL0080: Failed services" =>
> {"jboss.jgroups.channel.ee <http://jboss.jgroups.channel.ee>" =>
> "org.jboss.msc.service.StartException in service
> jboss.jgroups.channel.ee <http://jboss.jgroups.channel.ee>:
> java.security.PrivilegedActionException: java.net.BindException: [TCP]
> /0.0.0.0 <http://0.0.0.0> is not a valid address on any local network
> interface
>     Caused by: java.security.PrivilegedActionException:
> java.net.BindException: [TCP] /0.0.0.0 <http://0.0.0.0> is not a valid
> address on any local network interface
>     Caused by: java.net.BindException: [TCP] /0.0.0.0 <http://0.0.0.0>
> is not a valid address on any local network interface"}}
>
> This issue is similar to
> http://stackoverflow.com/questions/33141426/activemq-cant-be-bound-to-0-0-0-0-in-wildfly-10-0-0-cr2-in-profile-standalone-f
> but binding to an interface isn't a good solution in a docker context.
>
> I've also tried to see if this is tested somehow in Keycloak:
> http://lists.jboss.org/pipermail/keycloak-user/2016-November/008267.html


-- 
Bela Ban, JGroups lead (http://www.jgroups.org)


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi