Commit graph

747 commits

Author SHA1 Message Date
Karol Bucek
6f447440fe
Feat: conservative plugin (dependency) updates by default (#13794) (#13804)
(cherry picked from commit 67fd99b5b6)
2022-02-28 22:34:02 +00:00
kaisecheng
5197b340aa
Unpin bundler, fix gem installer tests (#13762) (#13776)
Fix gem installer tests to enable unpinning the version of bundler

This commit removes changes the gem installer to use real gems, rather than
use `allow_instance_of` during testing, which appears to be problematic with the
latest version of bundler
# Conflicts:
#	build.gradle

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-02-15 15:52:09 +00:00
Rob Bavey
292b2ebb57
Backport PR #13351 to 7.16: Fix bundler handling of 'without' (#13362)
Backport PR #13351 to 7.16 branch. Original message:

* Fix bundler handling of 'without'

Prior to this change, the values set in `set_local` are ignored when invoking
bundler via the command line, as is used with `invoke!`. This commit sets those
values in `ENV` variables instead, fixing the functionality to not install
development gems.
* Update bundler spec to check ENV variable
* Added test to ensure kramdown gem not vendored
* Re-add set_local setting to play nice with `expand_logstash_mixin_dependencies`
* logstash service needs to be installed
* gem_vendored? needs to use full path to vendor files
* use `stdout` from `cat` command to generate spec temporary file
* Removed unnecessary support for supplying a block from #gem_vendored?

Co-authored-by: Ry Biesemeyer <ry.biesemeyer@elastic.co>
2021-10-26 18:36:14 -04:00
kaisecheng
e3eede52e1
Fix plugin manager test that fail to fetch dependency (#13270) (#13271)
remove broken endpoint
Fixed: #13218
2021-10-05 14:09:58 +02:00
kaisecheng
f675a39841
unlock ecs_compatibility_support version in plugin update (#13218) (#13268)
This commit fixes the `logstash-plugin update` command which fail to update plugin
that depends on a new version of logstash-mixin-ecs_compatibility_support.
It resolves logstash-* dependencies and puts them in bundler update command.
Fixed: #13181
2021-10-04 15:33:56 +02:00
Andrea Selva
f063d86c31
Added test to cover the installation of aliased plugins (#12967) (#12998)
Added test to cover the installation of aliased plugins when exists a gem with same name but that's not a Logstash plugin.
In this case the alias is resolved to the original, skipping the gem retrieved from RubyGems.

(cherry picked from commit cafbf03158)
2021-06-17 17:01:14 +02:00
Andrea Selva
854fad6339
Avoid hard-coded plugin alias definitions (#12841) (#12960)
Remove hard coded alias definitions in favor of yaml descriptor file.

Introduce a single point of aliases definition (logstash-core/src/main/resources/org/logstash/plugins/AliasRegistry.yml),  checksum and copy it around to be used by Logstash and by Logstash's plugin management tool.

The descriptor yml file contains a checksum to verify it's not changed accidentally in a deployment of Logstash, if the verification phase fail Logstash avoid to start and plugin management tool avoid to operate.
The signing and copying around is managed by a specific Gradle task invoked during the build.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>

Fixes #12831

(cherry picked from commit 446dc7d906)
2021-06-16 17:34:46 +02:00
João Duarte
b3bcf29d73
use correct headers api for redirects in plugin manager http client (#12626) (#12628)
* fix plugin installation QA test

(cherry picked from commit 7c4bd8f875)
2021-02-01 16:08:21 +00:00
João Duarte
1fc169b7f6 Add apache and elastic license headers to source code files (#11673)
* add license header to ruby and java files
* add license header to erb and rake files
* add license headers to gradle files
2020-03-11 11:54:32 +00:00
João Duarte
4c57f52d8c Disable flaky test "should include the http address"
follow up at https://github.com/elastic/logstash/issues/11385

Fixes #11386
2019-12-04 10:13:43 +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
João Duarte
bef984143d
Revert "remove forced dependency on old bundler (#9395)"
This reverts commit ab20b40e47.

Due to failing tests like https://logstash-ci.elastic.co/job/elastic+logstash+master+multijob--ruby-unit-tests/86/
2018-12-03 13:49:54 +00:00
João Duarte
ab20b40e47
remove forced dependency on old bundler (#9395)
* update bundler to 1.17.1

This commit required some tweaking of how we setup Bundler
due to changes in reset behaviour, an internal variable name change,
and the Bundler::Settings api changing.
2018-11-30 09:25:24 +00:00
Josh Soref
c6cd247ec3 Multiple spelling corrections (#9782)
* spelling: actually
* spelling: already
* spelling: concurrency
* spelling: constructor
* spelling: destinations
* spelling: different
* spelling: elasticsearch
* spelling: encoding
* spelling: error
* spelling: explicitly
* spelling: failings
* spelling: falsey
* spelling: guarantees
* spelling: having
* spelling: implementation
* spelling: logstash
* spelling: module
* spelling: multiple
* spelling: omitted
* spelling: overridden
* spelling: pipeline
* spelling: raspberry
* spelling: receive
* spelling: recommended
* spelling: registered
* spelling: registering
* spelling: shutdown
* spelling: signal
* spelling: specified
* spelling: successful
* spelling: successfully
* spelling: valuefied
* spelling: vector
2018-07-04 10:41:10 +01:00
Ry Biesemeyer
a360dbb35c specs: temporarily use memory queue as a default
In an effort to stabilise our specs and reduce the amount of overflow from
each spec to the next, this patch temporarily sets the default queue type
to be the memory queue.

Fixes #9601
2018-05-18 20:21:13 +00:00
Ry Biesemeyer
5c0b8353b2 specs: improve isolation with per-spec temp data directory
Fixes #9517
2018-05-16 15:21:00 +00:00
Armin
fb01e68185 remove unused file
Fixes #9413
2018-04-25 12:48:14 +00:00
Andrew Cholakian
a1c0e417e5 Support for inter-pipeline comms with a new pipeline input/output
This also makes the load / reload cycle of pipelines threadsafe
and concurrent in the Agent class.

Fixes #9225
2018-04-10 23:48:58 +00:00
Tudor Golubenco
093603c378 Detect invalid proxy and raise error
As reported in #9132, if one sets `http_proxy=myproxy:8080` the URL
gets parsed to scheme=myproxy and host=nil. This results in a
NullPointerException.

To solve it, we check that the URL is valid as HTTP/HTTPs and raise a
slightly better error message.

Fixes #9132.

Fixes #9230
2018-03-15 18:17:08 +00:00
Armin
28e7467f9f Remove in memory serialized queue Ruby wrappers
Fixes #8999
2018-01-22 23:22:15 +00:00
Armin
c5fa78c7fa #8280 remove simplecov
Fixes #8536
2017-10-26 12:15:12 +00:00
Joao Duarte
88d6a3d3f4 fix a few issues with proxy handling when installing plugins
* allow installing a plugin using proxy without having to use the `--no-verify` flag
* allow the use of proxies that have basic authentication
* add tests for proxy handling in plugin manager

Fixes #8435
2017-10-05 11:50:33 +00:00
Colin Surprenant
21dbde2567 fixes for Windows platform tests/specs
use rm_rf to delete dir and shutdown pipeline after run

avoid the use of rescue nil, bad practice

do not mock close as it prevents closing the file an prevents removing it on Windows

cleanup temporary files and relax file name check for Windows

fix paths handling for Windows

flag the read file string as UTF-8 which is what we expect

fix Windows issues

ignore load_average on windows

windows safe URI

cleanup and fix file handling for windows

wait for pipeline shutdown to complete

revert to original puts

cleanups

use environment for windows platform check

fix hash path

wait for pipeline thread to complete after shutdown
2017-08-31 19:42:49 -04:00
Pier-Hugues Pellerin
76286b4f0e use jruby 9.1.9.0
Work done by @guyboertje and @ph

Since JRuby 1.7.25 is now EOL we are migrating Logstash to use JRuby 9k and JDK8 only,
Not much needed updating to make this work, its was mostly a drop in replacement from the previous version.

The major point was the change in the implementation of Time in JRuby, JRuby now use `java.time`
instead of joda time, this allow JRuby to have nanoseconds precision on time object.
2017-06-12 12:35:10 -04:00
Pier-Hugues Pellerin
fd6eb126c0 Add SSLError to the list of retryable exception
When building an offline pack we do a real network call to rubygems to
test the structure of the created package, something the network can be
a bit unreliable and SSLError can be raised, when theses errors happen
we will retry them.

Fix: #7251

Fixes #7254
2017-05-30 12:59:37 +00:00
Pier-Hugues Pellerin
1ea449f5a8 Reduce the scope of wilcards tests
Instead of downloading all the filter plugins we reduce the scope to
just download the `logstash-filter-x*` files, this will make the test
faster and reduce the risk of running into IOError.

Ref: #6904

Fixes #7211
2017-05-25 20:45:57 +00:00
Pier-Hugues Pellerin
dee9563e2f Add a retries on when testing packaging offline plugins
We have seen unreliable run in the past on travis or jenkins, in that
test we actually test the creation of a physical package we require
internet access to correctly download the gems, this commit make sure we
retries IOErrors.

Fixes: #6904

Fixes #7211
2017-05-25 20:45:56 +00:00
Andrew Cholakian
78f70634ed Refactor API specs to play well with others
This is a big chang, it:

1. Moves API specs out of their special hierarchy
2. Removes the API spec spec_helper
3. Reactivates that stats command spec (that was accidentally not being
run before due to it not having _spec as a suffix

This was required to fix the preceeding commit, where we added a
before(:each) hook to the spec_helper that wasn't being picked up in
some cases due to the existence of two spec helpers and a $LOAD_PATH
that could change.

Fixes #7132
2017-05-18 13:45:27 +00:00
Andrew Cholakian
ff222b668b Clean settings before *and* after spec runs for the runner just in case.
This is a bit belt and suspenders, but I'm out of ideas for #6737 .
Its a bit worrying that the test cleanup may not be working correctly

Fixes #7132
2017-05-18 13:45:27 +00:00
Rob Bavey
06823be008 Fix test failure when run from DNS hijacked ISP
Removes the tld from 'unreachable host' to circumvent DNS hijacking
ISPs returning a 200 response for non-existent domains.

Fixes #7124
2017-05-16 17:41:34 +00:00
Pier-Hugues Pellerin
0eb5342480 fix the ordering issue with the proxy test
Depending of the order of the test some test didn't not clear correctly
the environment.

Fixes #7080
2017-05-11 16:21:56 +00:00
Pier-Hugues Pellerin
276c6e9602 Check for empty string when configuring proxies
On some Linux system like debian, the `HTTP_PROXY` are set to an empty
string and was causing the plugin manager to raise an exception. We now
strip the string and check if it is empty before trying to configure the
proxies.

Fixes: #7045

Fixes #7065
2017-05-11 12:54:44 +00:00
Pier-Hugues Pellerin
e7acd48cc9 Make the OfflinePluginPackager test more robust
Add a #try to retry network related tests

Fixes: #6856

Fixes #6887
2017-04-20 15:21:36 +00:00
Pier-Hugues Pellerin
645fcec234 Refactor of the Agent class and the loading of the configuration
This PR introduces majors changes inside Logstash, to help build future
features like supporting multiple pipeline or java execution.

The previous implementation of the agent made the class hard to refactor or add new feature to it, because it needed to
know about too much internal of the pipeline and how the configuration existed.

The changes includes:
- Externalize the loading of the configuration file using a `SourceLoader`
- The source loader can support multiple sources and will aggregate them.
- We keep some metadata about the original file so the LIR can give better feedback.
- The Agent now ask the `SourceLoader` to know which configuration need to be run
- The Agent now uses a converge state strategy to handle: start, reload, stop
- Each actions executed on the pipeline are now extracted into their own classes to help with migration to a new pipeline execution.
- The pipeline now has a start method that handle the tread
- Better out of the box support for multiple pipeline (monitoring)
- Refactor of the spec of the agent

Fixes #6632
2017-04-14 11:42:00 +00:00
Andrew Cholakian
76711a4785 LIR UI (Read Only) (#6241)
* Read-only Java IR
* Consistent ID generation as opposed to UUIDs

Fixes #6708
2017-04-03 08:49:00 -04:00
Pier-Hugues Pellerin
4344e4b613 Allow Logstash to accept a PROXY configuration
Logstash's plugin manager will now follow proxy configuration from the environment.
If you configure `http_proxy` and `https_proxy`, the manager will now use theses information for all the ruby http
connection and will also pass that information down to maven.

Fixes: #6619, #6528

Fixes #6825
2017-03-31 14:20:38 -04:00
Pier-Hugues Pellerin
f74a7c9d56 Make sure prepare_offline_pack command only accept a filename
This PR changes the behavior of the command when you were specify a directory
instead of a filename, if the directory exists it would have deleted the
directory and the files in it.

The new flow and validation is now safer, if you specify a directory
Logstash will tell you to specify a complete filename.

If the ZIP extension is missing, the command line will ask you to make
sure you target a right filename.

If the output file already exist it will *not* delete it but instead
will return a warning message, you can force a delete by using the
`--overwrite` option.

Fixes: #6862

Fixes #6861
2017-03-31 11:05:17 -04:00
Josh Soref
a06dc211ff Spelling fixes (#6806)
Spelling fixes across the board.
2017-03-29 19:33:26 -07:00
Pier-Hugues Pellerin
c98b4ee1df Do not try to reach the artifact server when no plugins is given
This PR fix an annoyance when running the `bin/logstash-plugin install
--no-verify` without any plugins, the command was making an unnecessary
call to the artifacts web server.

Fixes #6826
2017-03-26 20:44:07 -04:00
Tal Levy
9974df427d remove old legacy logstash-core-event (#6783)
and migrate spec tests to core
2017-03-02 10:55:30 -08:00
Tal Levy
2e3b06b812 migrate core-queue-jruby into logstash-core (#6782) 2017-03-02 10:12:03 -08:00
Tal Levy
6fb8096a54 migrate logstash-core-event-java to logstash-core (#6760) 2017-03-01 15:31:17 -08:00
Pier-Hugues Pellerin
4377a76c88 Ignore NIL/EMPTY values for LOGSTASH_PACK_URL environment variable
Fixes #6611
2017-02-02 09:15:41 -05:00
Pier-Hugues Pellerin
86fad2b907 Allow 'Elastic' license in the spec
Allow plugin like the x-pack to use the elastic license

Fixes #6591
2017-01-26 12:54:17 -05:00
Pier-Hugues Pellerin
fdda39964d Add bin/logstash-plugin prepare-offline-pack command
This new command replace the old workflow of `pack`, `unpack` and the `install --local`, and wrap all the logic into one uniform way of installing plugins.
The work is based on the flow developed for installing an x-pack inside Logstash, when you call prepare-offline-pack, the specified plugins and their dependencies will be packaged in a zip.
And this zip can be installed with the same flow as the pack.

Definition:

Source Logstash: Where you run the prepare-offline-pack.
Target Logstash: Where you install the offline package.

PROS:
- If you install a .gem in the source logstash, the .gem and his dependencies will be bundled.
- The install flow doesn't need to have access to the internet.
- Nothing special need to be setup in the target logstash environment.

CONS:
- The is one minor drawback, the plugins need to have their JARS bundled with them for this flow to work, this is currently the case for all the official plugins.
- The source Logstash need to have access to the internet when you install plugins before packaging them.

Usage examples:
bin/logstash-plugin prepare-offline-pack logstash-input-beats
bin/logstash-plugin prepare-offline-pack logstash-filter-jdbc logstash-input-beats
bin/logstash-plugin prepare-offline-pack logstash-filter-*
bin/logstash-plugin prepare-offline-pack logstash-filter-* logstash-input-beats

How to install:
bin/logstash-plugin install file:///tmp/logstash-offline-plugins-XXXX.zip

Fixes #6404
2017-01-03 13:59:49 -05:00
Pier-Hugues Pellerin
2081fa626f remove the expect
Fixes #6340
2016-12-01 18:57:07 -05:00
Pier-Hugues Pellerin
bf2d670d2a Logstash-docgen tool v2
**Motivation**: We have decided to rewrite the documentation generator to add more features
to our documentation and to fix some outstanding bugs.

This PR addresses the following problem:
- Hard to add new features to the code base.
- The code was tied with Logstash.
- No easy way to publish the doc for a single plugin
- The plugin author was not able to test their documentation changes
- The reported errors were hard to understand.
- No easy way to automate it.
- the minimal requirement on base classes.

Fixes #5720
2016-11-30 19:57:40 -05:00
Pier-Hugues Pellerin
12cfa69215 Feature: A way to install/remove a plugin pack
A pack in this context is a *bundle* of plugins that can be distributed outside of rubygems; it is similar to what ES and kibana are doing, and
the user interface is modeled after them. See https://www.elastic.co/downloads/x-pack

**Do not mix it with the `bin/logstash-plugin pack/unpack` command.**

- it contains one or more plugins that need to be installed
- it is self-contains with the gems and the needed jars
- it is distributed as a zip file
- the file structure needs to follow some rules.

- As a reserved name name on elastic.co download http server
    - `bin/plugin install logstash-mypack` will check on the download server if a pack for the current specific logstash version exist and it will be downloaded, if it doesn't exist we fallback on rubygems.
    - The file on the server will follow this convention `logstash-mypack-{LOGSTASH_VERSION}.zip`

- As a fully qualified url
    - `bin/plugin install http://test.abc/logstash-mypack.zip`, if it exists it will be downloaded and installed if it does not we raise an error.

- As a local file
    - `bin/plugin install file:///tmp/logstash-mypack.zip`, if it exists it will be installed

Fixes #6168
2016-11-17 14:00:02 -05:00
Colin Surprenant
761f9f1bc9 merge feature/java_persistence into master 2016-11-01 17:13:23 -04:00
Tal Levy
1b2f7a7668 Migrate Logstash to Log4j2 Logging (#5651)
Migrate to use Log4j2 for Logstash logging
2016-08-25 10:30:22 -07:00