Bug 226265

Summary: textproc/elasticsearch6: default config and rc.d script use deprecated variables
Product: Ports & Packages Reporter: redlamb19
Component: Individual Port(s)Assignee: Mark Felder <feld>
Status: Closed FIXED    
Severity: Affects Many People CC: alex, mateusz
Priority: --- Flags: bugzilla: maintainer-feedback? (feld)
Version: Latest   
Hardware: amd64   
OS: Any   
Bug Depends on:    
Bug Blocks: 226248    
Attachments:
Description Flags
elasticsearch.in rc.d script (files/elasticsearch.in)
none
replacement for files/patch-config_elasticsearch.yml none

Description redlamb19 2018-02-28 16:35:22 UTC
Aside from the missing file(s) (ref bug ID 226248), the default configuration and rc.d script do not properly launch the elasticsearch service. 

Configuration (/usr/local/etc/elasticsearch/elasticsearch.yml):
1. path.scripts is no longer supported and results in an unknown setting exception. This configuration should be removed.

rc.d script (/usr/local/etc/rc.d/elasticsearch):
1. path.conf is no longer supported and results in an unknown setting exception.
2. ES_PATH_CONF=/usr/local/etc/elasticsearch needs to be set prior to launching ES.

Additionally, GC logging, which is enabled by default in ES 6, appears to be incorrectly configured and attempts to log to an invalid location. This does not appear to affect the execution of the service and simply prints an error to the screen. The location of the GC logging is set withing jvm.options.

I'll try to write patches for these fixes later today.
Comment 1 Mark Felder freebsd_committer freebsd_triage 2018-02-28 17:04:42 UTC
I'm working on this today as well. Once this is sorted I'm going to commit all the accompanying ports for Elastic.

Thanks for the hint about the GC log location.
Comment 2 Mateusz Kwiatkowski 2018-03-01 11:47:32 UTC
I can confirm that fixing errors listed here and in #226248 fixed starting Elasticsearch.

I'm now seeing "cannot register console handler because JNA is not available" followed by "fatal error in thread [main], exitting". I'll try to find out what's the cause of this one.
Comment 3 Mateusz Kwiatkowski 2018-03-01 12:37:05 UTC
# file /usr/local/lib/elasticsearch/lib/jna.jar
/usr/local/lib/elasticsearch/lib/jna.jar: broken symbolic link to ../../../../../../../../../../local/share/java/classes/jna.jar

I fixed this manually:
rm /usr/local/lib/elasticsearch/lib/jna.jar
ln -s /usr/local/share/java/classes/jna.jar /usr/local/lib/elasticsearch/lib/jna.jar

I also had to set path.data in elasticsearch.yml because default didn't work. Shouldn't it be set to /var/db/elasticsearch by default? I think that textutils/elasticsearch port did that.
Comment 4 redlamb19 2018-03-01 16:24:48 UTC
Created attachment 191109 [details]
elasticsearch.in rc.d script (files/elasticsearch.in)

replacement rc.d script for elasticsearch. Properly sets ES_PATH_CONF and removes the definition of path.conf. It also removes ES_JVM_OPTIONS, which appears to be no longer used/honored.
Comment 5 redlamb19 2018-03-01 16:27:45 UTC
Created attachment 191110 [details]
replacement for files/patch-config_elasticsearch.yml

Properly set path.data and path.logs. Note that path.scripts appears to be another variable that is removed in ES 6 as it results in an unknown setting exception. This also does not set the bootstrap.system_call_filter that appears be defined within the textproc/elasticsearch5 port.
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-03-01 23:37:43 UTC
A commit references this bug:

Author: feld
Date: Thu Mar  1 23:37:21 UTC 2018
New revision: 463358
URL: https://svnweb.freebsd.org/changeset/ports/463358

Log:
  textproc/elasticsearch6: Fix run issues

  - Elastic no longer accepts -Epath.conf argument. Change to ES_PATH_CONF env
  - Elastic was not honoring the elasticsearch_tmpdir rc.conf variable. Remove.
    The default behavior is to use mktemp for a unique tmpdir in /tmp. This seems sane,
    especially when running multiple profiles.
  - Patch jvm.options to set a writable location for gc.log, which will be the tmpdir.
    There is not an easy way to automatically point this to the log dir, so it needs
    a unique location when running muliple profiles.
  - devel/jca is also a BUILD dependency to fix build outside poudriere

  PR:		226265

Changes:
  head/textproc/elasticsearch6/Makefile
  head/textproc/elasticsearch6/files/elasticsearch.in
  head/textproc/elasticsearch6/files/patch-config_elasticsearch.yml
  head/textproc/elasticsearch6/files/patch-config_jvm.options
Comment 7 Alexey Egorov 2018-03-02 02:46:38 UTC
[2018-03-02T08:25:56,834][WARN ][o.e.b.Natives            ] JNA not found. native methods will be disabled.
java.lang.ClassNotFoundException: com.sun.jna.Native
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_121]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_121]
	at java.lang.Class.forName0(Native Method) ~[?:1.8.0_121]
	at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_121]
	at org.elasticsearch.bootstrap.Natives.<clinit>(Natives.java:45) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.2.2.jar:6.2.2]
[2018-03-02T08:25:56,847][WARN ][o.e.b.Natives            ] cannot check if running as root because JNA is not available
[2018-03-02T08:25:56,847][WARN ][o.e.b.Natives            ] cannot install system call filter because JNA is not available
[2018-03-02T08:25:56,848][WARN ][o.e.b.Natives            ] cannot register console handler because JNA is not available
[2018-03-02T08:25:56,852][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node0] fatal error in thread [main], exiting
java.lang.NoClassDefFoundError: com/sun/jna/win32/StdCallLibrary$StdCallCallback
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:143) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.2.jar:6.2.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.2.2.jar:6.2.2]
Caused by: java.lang.ClassNotFoundException: com.sun.jna.win32.StdCallLibrary$StdCallCallback
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_121]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_121]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_121]
	... 10 more
Comment 8 Alexey Egorov 2018-03-02 08:24:52 UTC
/usr/local/lib/elasticsearch/lib# ls -l
lrwxr-xr-x  1 root  wheel       62  2 марта 08:24 jna.jar- -> ../../../../../../../../../../local/share/java/classes/jna.jar

fixing bad symlink resolve problem
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-03-02 13:06:52 UTC
A commit references this bug:

Author: feld
Date: Fri Mar  2 13:06:24 UTC 2018
New revision: 463392
URL: https://svnweb.freebsd.org/changeset/ports/463392

Log:
  textproc/elasticsearch{5,6}: Fix symlink

  Relative symlinks should only be used when both files are in the
  STAGEDIR. In this situation poudriere was producing usable packages
  because of the unique location of WRKSRC (/wrksrc/...) which caused the
  relative symlink to be deep enough "../../../../../" to hit the root of the
  filesystem and then point to the location of the file. However, users
  who were building the port directory with "make" or "portmaster" were
  getting symlinks that did not point to the right location.

  PR:		226234 226265 222261

Changes:
  head/textproc/elasticsearch5/Makefile
  head/textproc/elasticsearch6/Makefile