Commit graph

259 commits

Author SHA1 Message Date
mergify[bot]
905ff93cec
Fix pqcheck and pqrepair on Windows (#17210) (#17263)
A recent change to pqheck, attempted to address an issue where the
pqcheck would not on Windows mahcines when located in a folder containing
a space, such as "C:\program files\elastic\logstash". While this fixed an
issue with spaces in folders, it introduced a new issue related to Java options,
and the pqcheck was still unable to run on Windows.

This PR attempts to address the issue, by removing the quotes around the Java options,
which caused the option parsing to fail, and instead removes the explicit setting of
the classpath - the use of `set CLASSPATH=` in the `:concat` function is sufficient
to set the classpath, and should also fix the spaces issue

Fixes: #17209
(cherry picked from commit ba5f21576c)

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2025-03-07 16:13:14 -05:00
github-actions[bot]
d622ff2272
entrypoint: avoid polluting stdout (#17125) (#17135)
routes output from setup-related functions to stderr, so that stdout can
include only the output of the actual program.

(cherry picked from commit 91258c3f98)

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2025-02-21 12:22:31 -08:00
kaisecheng
849f431033
fix Windows java not found log (#16633) 2024-11-05 10:15:51 +00:00
kaisecheng
4e82655cd5
remove ingest-converter (#16453)
Removed the tool Ingest Converter
2024-09-16 15:57:51 +01:00
Alex S
bc0b9556bd
Add quotes to fix path handling in pqcheck.bat (#16205) 2024-06-26 11:05:17 +01:00
Andrea Selva
26d1c7ccdb
Update to JRuby 9.4 (#14861)
Set of changes to make Logstash compatible to JRuby 9.4.
Bundle JRuby 9.4.3.0

- Redefine space token in `LSCL`  and `grammar` treetop from `_` which would generated methods in the form `def _0` (deprecated since `2.7`) to `sc`.
- `I18n.t` method doesn't accept hash as second argument
- `URI.encode` has been replaced with same functionality with `URI::Parser.new.escape`
- `YAML.load` needs explicit `fallback: false` to return false when the yaml string is empty (or contains only comments)
- JRuby's  `JavaClass` has been removed, now it can use `java.lang.Class` directly
- explicitly require gem `thwait` to satisfy `require "thwait"` (In `Gemfile.template` and `logstash-core/logstash-core.gemspec`)
- fix not args `clone` to be `def clone(*args)`
- fix `Enumeration.each_slice` which from `Ruby 3.1` is [chainable](https://rubyreferences.github.io/rubychanges/3.1.html#enumerableeach_cons-and-each_slice-return-a-receiver) and doesn't return `nil`. JRuby fixed in https://github.com/jruby/jruby/issues/7015
- Expanded `Down.download` arguments map ca16bbed3c302006967413eb9d3862f2da81f7ae
- Avoid to pass `nil` in the list of couples used in `Hash[ <list of couples> ]` which from Ruby `3.0` generates an `ArgumentError`
- Removed space not allowed between method name and parentheses `initialize (` is forbidden. 29b607dcdef98f81a73ad171639fd13aaa65e243
- With [Ruby 2.7 the `Kernel#open`](https://rubyreferences.github.io/rubychanges/2.7.html#network-and-web) doesn't fallback to `URI#open`, fixed test code that used that to verify open port. e5b70de54c5301f51a767da67294092af0cfafdc
- Avoid to drop `rdoc/` folder from vendored JRuby else `bin/logstash -i irb` would crash, commit b71f73e9c6edb81a7b7ae1305047e506f61c6e8c

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2023-06-28 13:05:43 +02:00
Andrea Selva
6bbe0700da
Retrive JVM_VERSION from Logstash's home directory (#14797)
Updates bootscripts common part to retrieve the JVM_VERSION file from the Logstash home directory
2023-01-12 13:56:51 +01:00
Rob Bavey
5d7fa78e09
Fix Windows scripts (#14515)
The work done in #14355 to fix the keystore and plugin scripts erroneously included
%JAVA_OPTS% in the command to invoke `jruby`, rather than as an environment variable, which
prevented these scripts from operating correctly, due to `jruby.exe` not handling Java options,
causing the scripts to crash on invocation.

This commit removes the %JAVA_OPTS% - this is already set as an environment variable, and allows the
scripts to operate correctly
2022-09-09 09:06:57 -04:00
Rob Bavey
59c5374849
Fix windows scripts to also pull settings from JvmOptionsParser (#14355)
* Fix windows scripts to also pull settings from JvmOptionsParser

Prior to this commit, the windows version of the keystore and plugin scripts
diverged from the bash version of these scripts, as they did not pick up Jvm Options
from the JvmOptionsParser, leading to certain mandatory settings not being picked up,
breaking compatibility with Windows on certain versions of the JDK. This PR ensures
that these scripts also use the JvmOptionsParser.

This does not resolve the issue described in #14176, which will be looked at in a future
PR

Relates: #14354

* Add goto :eof as per code review suggestion
2022-07-18 09:03:40 -04:00
Rob Bavey
4a2268a43f
Update jruby version to 9.3.4.0 (#14114)
This commit updates the version of jruby used in Logstash to `9.3.4.0`.

* Updates the references of `jruby` from `9.2.20.1` to `9.3.4.0`
* Updates references/locations of ruby from `2.5.0` to `2.6.0`
* Updates java imports including `org.logstash.util` to be quoted
  * Without quoting the name of the import, the following error is observed in tests:
  * `java.lang.NoClassDefFoundError: org/logstash/Util (wrong name: org/logstash/util)`
  * Maybe an instance of https://github.com/jruby/jruby/issues/4861
* Adds a monkey patch to `require` to resolve compatibility issue between latest `jruby` and `polyglot` gem 
  * The addition of https://github.com/jruby/jruby/pull/7145 to disallow circular
causes, will throw when `polyglot` is thrown into the mix, and stop logstash from
starting and building - any gems that use an exception to determine whether or not
to load the native gem, will trigger the code added in that commit.
  * This commit adds a monkey patch of `require` to rollback the circular cause exception
back to the original cause.
* Removes the use of the deprecated `JavaClass`
* Adds additional `require time` in `generate_build_metadata`
* Rewrites a test helper to avoid potentially calling `~>` on `FalseClass`


Co-authored-by: Joao Duarte <jsvduarte@gmail.com>
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-05-19 10:29:59 -04:00
Andrea Selva
fbcbb7084f
Print bundled jdk's version in launch scripts when LS_JAVA_HOME is provided (#13880)
Extracts the bundled JDK's version into a one-line text file which could easily read and print from bash/batch scripts.
Updates Logstash's bash/batch launcher scripts to print the bundled JDK version when warn the user about his override.

Updates the rake script used to create Logstash artifacts (rakelib/artifacts.rake) to include JDK related stuff only if packages that requires it.
2022-03-18 08:59:30 +01:00
Andrea Selva
a8bd90c22d
Quotes java executable path in case it contains spaces (#13881)
Updates all Windows batch scripts used as CLI tools to quotes the %JAVACMD% to avoid path problems when the path contains spaces.
2022-03-14 18:17:38 +01:00
Andrea Selva
0084492494
Fix Logstash cli tools to use the selected JDK under Windows (#13839)
Some Logstash tools invokes directly the JRuby intepreter. The interpreter uses the JVM pointed by two environment variables:
- JAVACMD
- JAVA_HOME\bin\java.exe

The setup.bat script exported the selected JVM under the env var named JAVA, which isn't recognized by vendored jruby.
This commit fixes it renaming to JAVACMD.
2022-03-07 15:05:52 +01:00
Karol Bucek
3637a30e8f
Refactor: drop redundant (jruby-complete.jar) dependency (#13159)
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-02-02 06:55:26 +01:00
Rob Bavey
0927da6422
Remove separate JavaVersionChecker executable (#13648)
* Remove separate JavaVersionChecker executable

The JavaVersionChecker is unnecessary as we already run the JvmOptionsParser before logstash,
providing a convenient location to test the Jvm version before running logstash

* Remove JavaVersionChecker class
* Check exit code from java options parser
2022-01-20 11:22:37 -05:00
Rob Bavey
55d6f21f31
Add JavaVersionChecker to check Java version for compatibility before running (#13533)
Provides a "friendly" error message when running Logstash with an incompatible
version of Java

Readded from #13356, incorporated with use of Comparable from #13358
2022-01-04 09:57:39 -05:00
Rob Bavey
e619b7ade1
Revert "Add JavaVersionChecker to check Java version for compatibility before… (#13356)" (#13364)
This reverts commit 620a654779.
2021-10-26 19:55:05 -04:00
Rob Bavey
620a654779
Add JavaVersionChecker to check Java version for compatibility before… (#13356)
* Add JavaVersionChecker to check Java version for compatibility before running

Provides a "friendly" error message when running Logstash with an incompatible
version of Java

* Add version check to Windows
* Improvements

Improve readability of `JavaVersion`
Fix logstash bash script to exit on JavaVersionChecker error
2021-10-26 18:50:42 -04:00
Andrea Selva
d51afe54d5
Removed JAVA_HOME using only LS_JAVA_HOME (#13214)
Removes the usage of JAVA_HOME completely which is not anymore used for JDK path resolution.

Updated all the Logstash launching scripts to use only LS_JAVA_HOME as environment variable to
determine the JDK to use to launch Logstash. JAVA_HOME is abandoned for this job.
2021-09-15 09:29:07 +02:00
Andrea Selva
3ffdb99119
Deprecate JAVA_HOME preferring LS_JAVA_HOME (#13207)
Adds print of deprecation notices on stdout when Logstash is starting with JAVA_HOME instead of LS_JAVA_HOME
2021-09-08 11:06:53 +02:00
Andrea Selva
979ea21c5e
Introduce LS_JAVA_HOME environment variable (#13204)
This commit modifies the launch scripts to take care of the LS_JAVA_HOME giving precedence over the JAVA_HOME, which is still used it the first is not found.
2021-09-06 10:22:51 +02:00
André Letterer
e249b5d6b4
valid variable expansion for the batch files (#12912) 2021-07-31 01:25:12 +02:00
Dion Williams
1f9ef97836
Fix logstash.bat not setting exit code (#12948)
This PR makes the Windows logstash.bat exit with the last %ERRORLEVEL% at the end, so that any error in running Logstash will get propagated back to the command line.

Before this change, logstash.bat would always exit with code 0 - success (when doing cmd.exe /C logstash.bat), even if the java.exe process exited with a non-zero code (e.g. due to Logstash throwing an error at runtime).
2021-06-21 10:32:53 +02:00
João Duarte
128e992c57
[windows] fix launch of logstash.bat when folder contains spaces (#12585) 2021-01-26 09:57:57 +00:00
andsel
7ba8c75458 Introduction of conditional in jvm.options file (#12530)
- moved parsing of jvm.options file into Java code
- chnaged the parsing code to consider conditional notation to bind the applicability of certain JVM flags to specific JVM versions
- changed the launch scripts (.sh and .bat) to use the options string composition
- binded CMS flags to JVM specifications 8-14
2021-01-25 05:16:18 -08:00
Rob Bavey
5c7d5ac8c0 Bundle JDK (AdoptOpenJDK 11) in Logstash artifacts (x86_64)
Create new artifacts with bundled JDK for the supported platforms on x86_64. Download JDK packages from AdoptOpenJDK site, the selected version is loaded from `versions.yml`.
Changed also the launch scripts to give precedence to JAVA_HOME, then fallback on bundled JDK if present, as last resource go to the system Java.

New artifacts produced with bundled JDK are:
- tar.gz with JDK for Linux and Darwin
- zip file for Windows
- dep and rpm
- Docker image

All artifacts without JDK are now postfixed with '-no-jdk' while the ones with JDK included has the architecture extension.

Covered with tests the touched parts

Co-authored-by: Rob Bavey <robbavey@users.noreply.github.com>
2020-09-23 08:18:31 -07:00
Ry Biesemeyer
1c3d3b88fd reword bin/system_install help text to be less confusing.
Present OPTIONSFILE search in a way that reads first-match-wins, since that is
what actually happens.

Resolves: #12145
2020-07-27 14:21:56 -07:00
André Letterer
bcb789d803 Update benchmark.bat
Fixes #11754
2020-04-21 16:36:26 +00:00
André Letterer
4149f7eebd Update pqrepair.bat
Fixes #11754
2020-04-21 16:36:26 +00:00
André Letterer
03c1ab94ff Update pqcheck.bat
Fixes #11754
2020-04-21 16:36:26 +00:00
André Letterer
eccb59903f Update benchmark.bat
Fixes #11754
2020-04-21 16:36:26 +00:00
André Letterer
902931cb85 tools convert to batch files (#11753)
Fixes #11754
2020-04-21 16:36:26 +00:00
Karol Bucek
84347a1518 Changed: base-line JRUBY_OPTS to default to --dev
Fixes #11355
2019-12-03 10:51:44 +00:00
Ry Biesemeyer
583ec6b625
Java 11 support (#10279)
* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (#10266)

* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef984143d.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
https://github.com/enkessler/childprocess/pull/141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
2019-02-04 16:36:11 -08:00
aristosvo
5ef181bfae Update logstash.bat to enable CLASSPATH with spaces
```Error: Could not find or load main class Files\Java\jdk1.8.0_172 org.logstash.Logstash -e input```

I had C:\Program Files\Java\jdk1.8.0_172 as part of my classpath, which caused this error. After adding " arround %CLASSPATH% it worked fine for me

Fixes #9898
2018-09-06 18:27:14 +00:00
Dan Hermann
9b73071e67 instructions on how to run tool, remove unused readlink call in script
Fixes #9931
2018-08-27 21:44:47 +00:00
George Xie
d1cafc393b system-install pass pleaserun exit code to outside
system-install should fail hard if pleaserun failed.
related with #9403

Fixes #9841
2018-07-23 17:21:24 +00:00
Colin Surprenant
1124d799a8 fix broken classpath when whitespaces are in the path #9832
reverse classpath jars order and remove trailing colon
2018-07-16 16:43:25 -04:00
Armin
6d0230aa4f PQ Repair Utility
Fixes #9710
2018-06-12 08:28:06 +00:00
Armin
3e14bc2741 JAVAFICATION: Javafy PqCheck Ruby Script
Fixes #9533
2018-05-07 13:13:32 +00:00
Dan Hermann
0e2186c36f remove unnecessary license mapping and shell function
Fixes #9331
2018-05-02 15:35:42 +00:00
Dan Hermann
48594baf2b Add license reporting task
Fixes #9331
2018-05-02 15:35:42 +00:00
Simon Lundström
c53c88819c Respect JAVACMD and update Drip docs to reality
Fixes #9373
2018-04-27 17:30:33 +00:00
Paul Pawlik
30401e3999 make -V/--version fast on Windows (#8508) 2018-02-21 11:16:00 -05:00
Liu Chong
9807016274 Replace command 'which' with 'command -v' for compatibility
I think we should not check if a command exists which another command, in here 'which'.
Instead we should use a build-in method, in order that script still works in some environments
that, such as a basic docker image, do not have a "which" command.

Fixes #8880
2018-02-07 17:43:20 +00:00
Colin Surprenant
2996062232 fix integration tests build 2018-01-24 10:26:56 -05:00
Jake Landis
058c9a6c47 Secret Store: Ability to set and use secret data from an encrypted data store.
Fixes #8657

Part 1: API and JavaKeyStore implementation (#8657)

Introduces the API to read/write/delete sensitive data from a secure store and includes a Java KeyStore implementation. Note - this commit does NOT integrate with the Logstash configuration or settings.

Part 2: Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support (#8659)

*  Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support

* Introduce a SecretStoreFactory to allow runtime definition of SecretStore implementation.
* Introduce a SecureConfig to allow simple configuration of different SecretStore implementaiton.
* Introduce random default password plus obfuscation. Best attempt at security through obscurity.
* Corrections / better support for x-JVM modification.

Part 3: Secret Store: SecretStore, SecretStoreFactory, JavaKeystore - refacactor (#8745)

* Adds more CRUD like operations for SecretStore API
* SecretStoreFactory Mirror API's CRUD operations
* Adds 'exists' to API to allow command line warning 'Overwrite ?'
* Minor readabiliy

Part 4: Integrate secret store with Logstash core (#8905)

This change introduces the command line tooling and hooks needed to allow Logstash to use the secret store. This change hooks into the same logic that the does the environment variable substitution. The commnad line mirrors the Elasticsearch command line, and is implemented primarily in Java.

Part 5: Hardening and test fixes (this PR)

Fixes #8935
2018-01-13 01:22:53 +00:00
Colin Surprenant
67c12393ac correctly handle paths with spaces 2018-01-11 13:28:15 -05:00
Armin
543b7221bd JAVA EntryPoint
* Created `org.logstash.Logstash` as entrypoint
* Safely handle `Ruby` runtime (which sadly is still a singleton, moving away from that will require a few iterations on top of this)
* Adjusted `bat` and `sh` entry point wrappers
* Verified manually that performance is unchanged (i.e. all Java opts are still loaded properly)
* Flattened `.jar` path to make it a little less bothersome to build the `-cp` string
* Retained ability to load jars from Ruby via the global `$LS_JARS_LOADED` variable hack, to keep plugin specs that load LS as a `.gem` functional (like e.g. the ITs in LS itself)
* No need for the gem jars magic anymore, the downloading and moving into place of jars is now all handled by Gradle

Fixes #8161
2018-01-03 19:13:28 +00:00
Armin
cd6d9c3a51 MINOR: Prevent enviornment GEM_DIR and GEM_PATH from leaking into build
Fixes #8896
2017-12-29 18:21:38 +00:00