You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/08/31 22:50:27 UTC

[GitHub] [accumulo] melaquias opened a new issue, #2908: MiniAccumuloCluster binds admin.serverPort to 8080

melaquias opened a new issue, #2908:
URL: https://github.com/apache/accumulo/issues/2908

   **Describe the bug**
   
   The MiniAccumuloCluster implementation makes no allowance for setting the 'admin.serverPort' property of the site config (conf/zoo.cfg file).   Thus, upon startup, Zookeeper will default to using port 8080 for the Jetty Admin service.   This is problematic since that port is very likely to be in use on many systems, resulting in a bind exception.
   
   This renders the MiniAccumuloCluster useless for implementing unit tests since unit tests need to be portable.
   
   **Versions (OS, Maven, Java, and others, as appropriate):**
    - Affected version(s) of this project: accumulo-2.0.1, zookeeper-3.6.2.jar
    - OS: confirmed behavior on both RHEL8 (Linux) and Mac OS (12.5.1)
    - Others:  JDK8 and JDK11
   
   **To Reproduce**
   Steps to reproduce the behavior (or a link to an example repository that reproduces the problem):
   1. Write code that starts up the MiniAccumulo cluster, in the recommended manner:
   
   ```
   MiniAccumuloCluster mac = new MiniAccumuloCluster(myDir, myRootPW);
   mac.start()
   ```
   2.  Compile.
   
   3.  Run
   
   **Expected behavior**
   
   The expected behavior is that the MiniAccumuloCluster will startup.
   
   **Actual behavior**
   
   The actual behavior is that it will not start up if another process is bound to port 8080.  In that situation a bind exception occurs and the zookeeper process does not successfully start.   Snippet of output:
   
   ```
   nested exception is org.apache.accumulo.miniclusterImpl.ZooKeeperBindException: Zookeeper did not start within 20 seconds. Check the logs in /Users/me21969/gits/pala/pala-client/target/tmp/1661984844776-0/miniacc/logs for errors.
   ```
   
   The default MiniAccumuloCluster configuration has limited log output.   By stepping through the debugger I was able to extract the actual commands used to exec the zookeeper process.  With that it is possible to execute that against the the config directories that are created, adding a higher fidelity log4j.properties file, which shows the more detailed trace:
   
   ```
   2022-08-31 18:36:01 ERROR ZooKeeperServerMain:85 - Unable to start AdminServer, exiting abnormally
   org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
   	at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:180)
   	at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:153)
   	at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:112)
   	at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:67)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.accumulo.start.Main.lambda$execMainClass$1(Main.java:166)
   	at java.lang.Thread.run(Thread.java:750)
   Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
   	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)
   	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)
   	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
   	at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.server.Server.doStart(Server.java:401)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:171)
   	... 9 more
   Caused by: java.net.BindException: Address already in use
   	at sun.nio.ch.Net.bind0(Native Method)
   	at sun.nio.ch.Net.bind(Net.java:461)
   	at sun.nio.ch.Net.bind(Net.java:453)
   	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222)
   	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85)
   	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
   	... 16 more
   ```
   editing the conf/zoo.cfg file manually and adding:
   
   ```
   admin.serverPort=8088
   ```
   
   (or any free port value) results in a successful startup of zookeeper.
   
   ***Workaround***
   None that I could think of.  The MiniAccumuloConfig & MiniAccumuloConfigImpl are in sealed packages and have default access to the setProperty() method and no accessible means to set the "admin.serverPort" property.   So this cannot be worked around via sub-classing & overrides.
   
   ***Suggested fix:***
   
   There are a couple of potential solutions:
   
   1. (Preferred) Make the MiniAccumuloConfigImpl.setProperty(String,String) method accessible to client code (preferably by way of a public method on the MiniAccumuloConfig class) such that properties such as this can be tuned by the client code prior to calling MiniAccumuloCluster.start().  This would allow writing code that looks something like so:
   
   ```
   MiniAccumuloConfig config = new MiniAccumuloConfig(myDir, myRootPW);
   config.setProperty("admin.serverPort", myFreePortValue);
   MiniAccumuloCluster Mac = new MiniAccumuloCluster(config);
   mac.start();
   ```
   
   2. (Less optimal) Alternatively, modify the MiniAccumuloConfigImpl.initialize() method to set the "admin.serverPort" to some random port value.   This would at least get it started, but is not optimal since it is not deterministic.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on issue #2908:
URL: https://github.com/apache/accumulo/issues/2908#issuecomment-1234575819

   > Except, duh-uh, of course setting the system property doesn't work - because MAC spawns ZK in a separate JVM process. Sigh ... I'll have to resort to one of the uglier work-arounds.
   
   Using non-public API is not recommended because internal code can change often. However, you might be able to do something like:
   
   ```java
   var config = new MiniAccumuloConfigImpl(new File("/"), "");
   
   var map = new HashMap<>(config.getSystemProperties());
   map.put("zookeeper.admin.enableServer", "false");
   config.setSystemProperties(map);
   
   var mac = new MiniAccumuloClusterImpl(config);
   mac.start();
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] melaquias commented on issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080

Posted by GitBox <gi...@apache.org>.
melaquias commented on issue #2908:
URL: https://github.com/apache/accumulo/issues/2908#issuecomment-1233685640

   Okay.  Thanks for the heads-up that this is fixed in the coming release and the work-around suggestions.  I should be able to make use of one of them.  Using v3.4 of ZK is not an option.   The system property for disabling the admin server looks like that should work.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] melaquias commented on issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080

Posted by GitBox <gi...@apache.org>.
melaquias commented on issue #2908:
URL: https://github.com/apache/accumulo/issues/2908#issuecomment-1233692550

   Except, duh-uh, of course setting the system property doesn't work - because MAC spawns ZK in a separate JVM process.  Sigh ... I'll have to resort to one of the uglier work-arounds.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on issue #2908:
URL: https://github.com/apache/accumulo/issues/2908#issuecomment-1233544930

   Closing this as already addressed in the next release. See below for workarounds for previous releases.
   
   This only affects older Accumulo versions using a newer version of ZooKeeper that those Accumulo versions were not explicitly designed to work with. While newer versions of ZooKeeper should work with Accumulo 2.0 and 1.10, there may be some newer features in newer ZooKeeper releases that these versions of Accumulo do not explicitly support. Accumulo 1.10 and 2.0 were developed and tested primarily with ZooKeeper 3.4, which did not have an adminServer. The way we support arbitrary ZooKeeper configuration for mini is by providing the ability to use a ZooKeeper instance you start yourself.
   
   Mini itself does not use the adminServer and disables it in 2.1.0-SNAPSHOT (see #1531), so it's will not be an issue in that version, which will be the first version to be written explicitly to support ZooKeeper 3.5 and newer, after the adminServer was introduced.
   
   The workaround for this would be to use an existing ZooKeeper instance, which you can set up separately using whatever zoo.cfg you prefer. This is supported in the MiniAccumuloCluster API for Accumulo 1.10 and 2.0. You could use something like revelc/zookeeper-maven-plugin or start ZooKeeper yourself.
   
   Another workaround that ZooKeeper itself supports is: `System.setProperty("zookeeper.admin.enableServer", "false");`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii closed issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080

Posted by GitBox <gi...@apache.org>.
ctubbsii closed issue #2908: MiniAccumuloCluster binds admin.serverPort to 8080
URL: https://github.com/apache/accumulo/issues/2908


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org