Commit graph

197 commits

Author SHA1 Message Date
github-actions[bot]
2cf0717164
regenerate webserver test certificates (#16331) (#16334)
(cherry picked from commit c30aa1c7f5)

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2024-07-17 10:45:23 +01:00
github-actions[bot]
438a6cf6f9
Fix flaky logstash-plugin IT test (#15803) (#15818)
This commit fixes the flaky IT test:
`install non bundle plugin successfully installs the plugin with debug enabled`
by being a bit more lenient with the output which can get garbled by Bundler.

Closes #15801

(cherry picked from commit fc09ad4112)

Co-authored-by: Dimitrios Liappis <dimitrios.liappis@gmail.com>
2024-01-18 15:33:20 +02:00
github-actions[bot]
5f0838c0b6
Pin childprocess gem to major version 4 (#15758) (#15762)
This commit pins the `childprocess` gem to version `4` since version `5.0.0` of
https://github.com/enkessler/childprocess/pull/175 seems to have broken JRuby support for spawning.

Closes https://github.com/elastic/logstash/issues/15757

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
(cherry picked from commit 9f1d55c6a2)

Co-authored-by: Dimitrios Liappis <dimitrios.liappis@gmail.com>
2024-01-08 19:01:57 +02:00
github-actions[bot]
6ac076092e
specs: assert presence of logging without risking NoMethodError (#14633) (#14719)
* specs: assert presence of logging without risking NoMethodError

* Update qa/integration/specs/monitoring_api_spec.rb

(cherry picked from commit 9460d4d7fc)

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2023-07-18 10:48:53 +01:00
github-actions[bot]
525fd342f1
Fix debug output for bin/logstash-plugin (#14132) (#14144)
When run in debug mode, #invoke was returning an instance of UI::Shell rather
than a string, causing the plugin to crash when `<<` was called on.
This commit ensures that a string is returned regardless of whether debug is set

Fixes: #14131
(cherry picked from commit 02c2aec710)

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-09-26 14:54:06 -04:00
github-actions[bot]
ee24f3ce38
update flores dependency to at least 0.0.8 (#14437) (#14449)
(cherry picked from commit 4cb900ce7e)

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-08-17 09:58:15 +01:00
kaisecheng
bd39da7b2c
[7.17] Allow metrics update when PQ draining (#13935) | fix monitoring api integration test with draining queue (#14106) (#14108)
* Allow metrics update when PQ draining (#13935)

This commit moves the stop of metrics collection after pipelines shutdown to allow metrics update during PQ draining
Fixed: #13832

(cherry picked from commit 0af9fb0d5f)

* fix monitoring api integration test with draining queue (#14106)

This commit ends the integration test with teardown instead of sending a signal to kill
Related: #13935

(cherry picked from commit 7641b076f4)
2022-05-17 10:40:42 +01:00
github-actions[bot]
07f4292275
Updates the LogstashService launcher to use the JDK specified (#13946) (#13947)
Sets the LS_JAVA_HOME environment variable for the environments used to spawn Logstash process in integration tests.
The JDK matrix testing is based on selecting the desired JDK to run the tests, through the BUILD_JAVA_HOME.
However, when the integration tests spawn a Logstash process this setting was missed.

(cherry picked from commit d2739a875c)

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
2022-04-20 13:31:42 +01:00
Karen Metts
45c8442f59
Doc:Update qa readme with BUILD_JAVA_HOME setting info [7.17] (#13780)
Backports #11985 to 7.17
Co-authored-by: Rob Bavey rob.bavey@elastic.co
2022-02-15 20:25:42 -05:00
kaisecheng
d2a98a0b77
Support env variable in condition (#13608) (#13678)
This PR substitutes ${VAR} in Expression, except RegexValueExpression, with the value in secret store, env.
The substitution happens after syntax parsing and before graph execution.

Fixed: #5115
2022-01-25 16:22:37 -08:00
Andrea Selva
289ea89b2d
[Backport 7.17] Test fix, switch to plugin with less dependencies (#13672) (#13674)
Clean backport of #13672 to 7.17 branch

----

Fixes an integration test that verifies the capabilities of CLI tool to install a not bundled plugin.
Move away from logstash-input-google_cloud_storage which depends indirectly to OS's package named shared-mime-info, which is not always available.

(cherry picked from commit 7bb56e46dd)
2022-01-25 16:33:31 +01:00
Andrea Selva
779a4d5f13
[Backport 7.17] Fix Ruby port check execution in kafka_setup.sh (#13631) (#13640)
Clean backport of #13631 to 7.17

Original message:

When the Bash script executes the vendored Ruby it has to use proper `GEM_HOME` to avoid the overwrite that happens inside the logstash.lib.sh
3064f7d0c3/bin/logstash.lib.sh (L161-L165)

(cherry picked from commit 93f37b9609)
2022-01-20 08:58:19 +01:00
Andrea Selva
9c4fdf8892
[Backport 7.17] Fix/gems not found in integration test after plugin install (#13641) (#13643)
Clean backport of #13641 to 7.17

Original message:

Cleanly teardown an integration test that made fall other integration tests.
In some cases the CI integration tests fails because the launched Logstash can't find a gem named `mimemagic`. This gem is installed during a CLI plugin test (install of  `logstash-input-google_cloud_storage` plugins kicks in that `mimemagic`).

(cherry picked from commit 640ba8489f)
2022-01-20 08:56:52 +01:00
Ry Biesemeyer
36c5e2a097
Backport PR #13525 to 7.17: fix: respect LS_JAVA_OPTS environment even when optionsfile missing (#13635)
* fix: respect LS_JAVA_OPTS environment even when optionsfile missing (#13525)

* fix: respect LS_JAVA_OPTS environment even when optionsfile missing

* Fixed integration tests

* Added unit test to cover the fix

* Wipe commented code

* Removed redundant log in a path that could never be reached

* Moved jvm.options checks into only one place

* javaopts: provide injection point for environment string

Co-authored-by: andsel <selva.andre@gmail.com>
(cherry picked from commit 2a248b2ea0)

* backport: spec silencing noise
2022-01-18 10:10:39 -08:00
Andrea Selva
dc4368e0c6
[backport 7.17]Avoid to increment event.out conter for dropped events (#13593) (#13624)
Clean backport of #13593 to 7.17 branch

----

Original message:

Fixes the issue #8752 in event.out counter. When a pipeline contains a drop filter the total out events counter should count only the events that reached the out stage.

This PR changes CompiledExecution.compute() interface to return the number of events that effectively reached the end of the pipeline. This change is used in WorkerLoop to update correctly the event.out metric, instead of relying on the batch's size.

(cherry picked from commit b6da829f4f)
2022-01-17 09:38:12 +01:00
kaisecheng
c77994f438
Fix logstash-plugin install command to install non default plugin (#13405) (#13587)
After the fix of unlocking ecs_compatibility_support version in plugin update (#13218), `logstash-plugin install` has a problem of installing non default plugin.
This commit removes `Bundler.setup` in install path to avoid Gemfile froze by bundler
Fixed: #13404

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2022-01-06 14:52:25 +00:00
Ry Biesemeyer
0603651ba7
Secure API (Backport to 7.x) (#13342)
* settings: add "deprecated alias" support

A deprecated alias provides a path for renaming a setting.

 - When a deprecated alias is set on its own, a deprecation notice is emitted
   but fetching the canonical setting value will reflect the value set with the
   deprecated alias.
 - When both the canonical setting (new name) and the deprecated alias (old
   name) are specified, it is an error condition.
 - When the value of the deprecated alias is queried, a warning is emitted to
   the logger and only the value explicitly set to the deprecated alias is
   returned.

Additionally, some relevant cleanup is also included:

 - Starting Logstash with invalid settings no longer results in the obtuse "An
   unexpected error occurred" with backtrace and exception data obscuring the
   issue. Instead, a simple message is emitted indicating that the settings are
   invalid along with the originating exception's message.
 - The various settings implementations share a common logger, instead of each
   implementation class providing its own. This is aimed to reduce noise from
   the logs and to ensure specs validating logging do not need to tie so
   closely to implementation details.

* settings: add password-wrapped setting

* settings: make any setting type capable of being nullable

* settings: add `Settings#names` to power programatic iteration

* cli: route CLI-flag deprecations in to deprecation logger

* settings: group API-related settings under `api.*`

retains deprecated aliases, and is fully backward-compatible.

* webserver: cleanup orphaned attr accessors for never-set ivars

* api: pull settings extraction down from agent

This net-no-change refactor introduces a new method `WebServer#from_settings`
that bridges the gap between Logstash settings and Puma-related options, so
that future additions to the API settings don't add complexity to the Agent.

It also has the benefit of initializing the API Rack App and just ONCE, instead
of once per attempted HTTP port.

* api: add optional TLS/SSL

* docs: reference API security settings

* api: when configured securely, bind to all available interfaces by default

* cleanup: remove unused cert artifacts

* tests: generate fresh webserver certificates

* certs: actually add the binary keystores 🤦
2021-10-19 14:13:37 -07:00
Andrea Selva
7202c5860e
Updates the clauses used to filter out from stderr captured messages (#13336)
Fixes an integration test that expects some output on the stderr.
With PR #13207 was added a deprecation notice to inform the user about the removal of support for JAVA_HOME. This notice is present only on 7.x and that console output needs to be removed in a test that verify installation of plugins.
2021-10-19 10:41:12 +02:00
Andrea Selva
2e6ed1d7e4
Fixes to build and run Logstah on JDK 17 (#13306) (#13331)
Backport #13306 to branch 7.x

(cherry picked from commit 7395641a43)

----

This commit applies all the changes needed to run Logstash on JDK 17:
- opens access to module java.base for packages sun.nio.ch and java.io to run the application and to execute the tests
- removes SecurityManager classes used during Logstash startup
- fix exception type catched in JavaKeyStore tampering test

Related to meta issue #13306
2021-10-18 16:38:38 +02:00
Rob Bavey
a2d45ccee6
Backport PR #13316 to 7.x: Fix Elasticsearch integration test to use specified JDK (#13323)
Backport PR #13316 to 7.x branch. Original message:

Sets `LS_JAVA_HOME` of the spawned logstash to use the same `java.home`
that the test is running under, rather than default to the system JDK, which
would result in the spawned logstash running under a different JDK to that
intended in the test
2021-10-15 15:22:50 -04:00
João Duarte
6983129f47
don't require mutate filter on remove_spec (#13292) (#13309)
(cherry picked from commit f70350ba12)
2021-10-13 14:22:49 +01:00
Rob Bavey
aeb3dc2cf3
Backport PR#13248 to 7.x: Fix kafka download link for integration tests (#13250)
Backport PR #13248 to 7.x branch. Original Message:

Fix kafka download link for integration tests

(cherry picked from commit aa1aa8e)
2021-09-27 12:17:11 -04:00
Andrea Selva
82993fa6f1
[backport 7.x] Use LS_JAVA_HOME in favor of JAVA_HOME #12725 (#13213)
Backport of #13204 #13207 to 7.x branch, introduces the LS_JAVA_HOME as preferred environment variable over JAVA_HOME which is deprecated.
2021-09-08 15:20:34 +02:00
Andrea Selva
959248ac4d
[backport 7.x] Gradle 7 updates, issue #13177 (#13212)
This commit is a backport of three PRs #13182 #13183 #13184
Mainly it switched the Gradle to version 7 and applies fixes to make it run.
2021-09-08 15:16:52 +02:00
Karol Bucek
6a56b96f9b
Backport #13164: Test: improve monitoring api logging asserts (#13169) 2021-08-25 18:51:00 +02:00
Rob Bavey
cc06c5d8f5
Backport PR #13005 to 7.x: update fpm to allow pkg creation on jdk11+jruby 9.2 (#13005) (#13144)
Backport PR #13005 to 7.x branch. Original Message:

* fpm to 1.13.0 which allows building packages with java 11 + jruby 9.2
* childprocess to 4.x + remove monkey patches
* clamp to 1.x to unlock fpm 1.13.0

(cherry picked from commit 7390b64)

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2021-08-17 18:21:42 -04:00
Ry Biesemeyer
4dcc69d97c
ispec: fix cross-spec leak from fatal error integration specs (#13002) (#13013)
Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.

(cherry picked from commit 6032e5ff64)
2021-06-21 10:59:51 -07:00
Andrea Selva
db726ab6f0
Fix/log4j routing to avoid create spurious file (#12965) (#12999)
Avoid the creation of log4j routing appender for log events without the `pipeline.id` fishtag.
In this way no spurious log file named "pipeline_${ctx:pipeline.id}.log" and logs are not duplicated with main Logstash log file.

(cherry picked from commit 1d6a3e4bb3)
2021-06-18 08:31:49 +02:00
Andrea Selva
138b60c839
Explicitate the type of log format in appender's names (#12964) (#12997)
Remove an useful dynamic creation of appender's log file which leverages the `log.format` property
also when it's explicit by the appender itself.

Log4j configuration leverages the placeholder `${sys:ls.log.format}` to compose the name of the log file.
This generates some not evident conflicts in log4j internals, these conflicts became evident when enabling the `pipeline.separate_logs` feature is enabled and the log4j appender definitions contains both json and plain format.
The problem is that under those circumstances the rollover of the log file doesn't happen.

This commit also add a test against the production log4j configuration, to avoid future regressions.

(cherry picked from commit a0774c4e76)
2021-06-17 14:21:24 +02:00
Karol Bucek
9cf722d30b
Test: handle a RGs warning from packing output (#12974)
in preparation for JRuby 9.2.18.0 which includes a RGs update
2021-06-10 06:41:01 +02:00
Andrea Selva
f93b30cca4
Use the JVM specified in the CI matrix environment also to run spawned proccesses (#12945) (#12953)
logstash-keystore integration tests spawn a Java process, which by default uses the system JDK generally exposed with JAVA_HOME environment variable. It could be that this JDK is not the one selected with the build system variable BUILD_JAVA_HOME.
This commit uses the JDK defined in BUILD_JAVA_HOME if present.

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
(cherry picked from commit fa9adb4b86)
2021-06-01 14:21:13 +02:00
Karol Bucek
a914a7c134
Backport PR #12784 (#12805) to 7.x: Fix: logstash-keystore failing with an error (#12803)
* Fix: logstash-keystore failing with an error (#12784)

* Fix: missing password dependency require

which causes `bin/logstash-keystore` to fail with an error:
```
ERROR: Failed to load settings file from "path.settings". Aborting...
path.setting=/logstash-7.12.0/config, exception=NameError,
message=>uninitialized constant LogStash::Util::Password

```

* Fix: review all LS parts depending on Password

* Test: bin/logstash-keystore create/list

(cherry picked from commit e8e393bdc7)

* Test: let's do the cleanup for every test
2021-04-08 18:19:01 +02:00
Rob Bavey
a61a827bb1
[7x backport] Fix Elasticsearch/DLQ integration test flakiness (#12695)
Clean backport of #12685

This commit fixes up some IT flakiness which has been presenting mostly
in recent DLQ test failures, it includes the following improvements:

 * A recent change to Elasticsearch has required the cluster setting
`action.destructive_requires_name` to be set to `false` to enable the use
of destruction actions with wildcards. This commit sets this before
tests on Elasticsearch and DLQ tests
 * Adds some extra safety to the `have_hits` rspec matcher
2021-02-23 16:05:18 -05:00
andsel
567487fdce Make integration test fail if 'offline' tool can't be compiled
(cherry picked from commit 042d0d466b)
2021-02-18 02:53:12 -08:00
João Duarte
91c27cd731
fix url for kafka and bump to 2.7.0 (#12617) (#12619)
Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
(cherry picked from commit 0337835f67)
2021-01-30 17:33:17 +00:00
Joao Duarte
d0f1ed4c71 Revert "replace with_clean_env with with_unbundled_env (#12615) (#12618)"
This reverts commit ff3cf929fa.

Because we're still on bundler 1.x here..
2021-01-29 17:56:58 +00:00
João Duarte
ff3cf929fa
replace with_clean_env with with_unbundled_env (#12615) (#12618)
(cherry picked from commit 023e11a8e2)
2021-01-29 17:35:47 +00:00
andsel
b0c81338f3 Implements scripted log4j filters and appenders to Java, avoid usage of deprecated Javascript Nashorn (#12512)
- replaces all scripted filters with custom Java implementation
- implemented routing appender per pipeline in Java
- adapted log4j configuration shipped with Logstash
- print a warn message if it detects an scripted log4j configuration and continue the execution (#12591)
2021-01-25 05:46:27 -08:00
Karol Bucek
53e73e9ccc
Fix: make sure LS exits when running into fatal errors (#12559)
Currently, LS does not respect fatal errors such as java.lang.OutOfMemoryError and continues executing.

This is dangerous since JVM errors are a legitimate reason to halt the process and not continue processing.

Additionally:

-   make sure we log the full stack-trace on fatal errors
-   halt the JVM wout executing finalizers/hook (scissors on how ES handles uncaught exceptions)
-   also, we should now be aware of a potentially unexpectedly dying thread

Back-port of #12470
2021-01-13 06:45:16 +01:00
Karol Bucek
a693fa3bf4
Build: properly isolate integration (test) env setup (#12364)
to avoid gems being resolved from the usual LS GEM_HOME

this is problematic for gems such as jruby-openssl which are loaded
during boot (by RGs/Bundler) and thus activated in Bundler from a
different GEM_HOME. if such gem is updated it won't end up being
install-ed in the --path location as it's found on the GEM_HOME!

+ Fix: gem conflict 1.3.6 required by core
this is due now isolating GEM_HOME on `bundle install --path`

+ Refactor: we do not need LS_GEM_HOME/PATH

+ avoid pinning jruby-openssl to 0.10.4

resolves GH-12299 (reverting GH-12301)
2020-10-20 09:00:01 +02:00
Rob Bavey
708c156c1b
[7x backport] Write DLQ entries to temp file first (#12304) (#12318)
Clean backport of #12304

This commit changes the DLQ writer to write to a temporary file
 which will be renamed on "completion", to avoid the possibility
 of the DLQ reader reading an incomplete DLQ segment. The temp file
 will be renamed and made available, either when the capacity of this
 segment is reached, or if a configurable 'flush interval' has elapsed
 since the last event reached the dead letter queue.

This commit fixes #8022, #10275, #10967
This commit replaces #11127
2020-10-07 14:37:49 -04:00
Rob Bavey
813e059a9d 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-30 05:44:42 -07:00
andsel
c0d9b025e5 Fix to implement the blank? method that doesn't exists for String, is added by Rails framework 2020-09-04 14:29:03 +00:00
Rob Bavey
7a4b81363b Fix kafka setup scripts
This commit updates the kafka setup scripts to ensure that the kafka setup is clean between builds, by
setting an explicit zookeeper data directory to be cleaned each time, and correctly overriding `log.dirs`
instead of `log.dir` to ensure that the kafka logs are written and wiped in a consistent place each time,
which helps when using the non-immutable images used in arm64 tests.
2020-07-13 17:49:23 +00:00
Rob Bavey
40f99249e6 Clear JAVA_HOME to use bundled JDK for Elasticsearch
This commit clears the `JAVA_HOME` variable when starting Elasticsearch
to force it to use the bundled version of the JDK, rather than the
default `JAVA_HOME` from the machine Logstash integration tests are being
run on, and removes the likelihood of tests failing to run due to `JAVA_HOME`
being set to a non-compliant JDK.
2020-07-08 13:01:41 +00:00
Rob Bavey
5a20843c8c
[7x backport] Add wait functionality to stop_es integration test helper function (#12067)
Integration tests may fail during elasticsearch teardown, as currently
the stop_es function sends a `SIGTERM` to Elasticsearch, but does not
wait for the process to exit. That can lead to issues when deleting
data directories from a still running process. This commit adds
wait functionality to `stop_es` to wait for a short period of time,
sending a `SIGKILL` if Elasticsearch does not terminate in time.

Clean backport of #12061
2020-07-02 11:35:45 -04:00
Rob Bavey
1a0d5c961f Use branch appropriate version of Elasticsearch
Carrying on from the work done in #11958, update the gradle build to download
the same version of Elasticsearch as is specified in the logstash version.yml file.
This commit updates the standard integration tests to use the same version of
Elasticsearch that is already downloaded for x-pack integration tests, and also
fixes integration tests to allow for the different responses around hits generated
by different versions of Elasticsearch.
2020-06-16 13:32:16 +00:00
Joao Duarte
7f58596643 remove uses of JSON.load in favor or JSON.parse
JSON.load allows the creation of complex objects, and should not
be given untrusted input. This commit changes the only three uses
of JSON.load in the codebase, which aren't user facing or present
in bundled product, so not really an attact vector.
2020-06-12 14:48:05 +00:00
Rob Bavey
addcb8a0a7
Retrieve branch version of Filebeat via gradle (#12011)
Clean backport of #11958

This commit changes the download to pull the version of beats based on the version pulled from the branch rather than from an environment variable, or 6.5.4.
This commit also moves the download logic of Filebeat fromfilebeat_setup.sh to build.gradle in order to use the artifacts API in the same way as the downloadEs task, and does some refactoring to DRY up the artifact download tasks.
This commit also fixes the beats integration test to replace the use of a removed setting.
This commit also sets retries to 3 for the download tasks, using 'retries' functionality from gradle download task plugin
2020-06-12 09:27:18 -04:00
Joao Duarte
e5f1e613ef update log4j script routes definition
fixes the change introduced with https://issues.apache.org/jira/browse/LOG4J2-2647
2020-06-09 13:26:30 +00:00