Commit Graph

61 Commits

Author SHA1 Message Date
Lee Hinman 7cb5378f82 Fix compilation after merging XContent changes
A backport missed these usages that had been removed.

Original commit: elastic/x-pack-elasticsearch@9e47562dd1
2018-03-20 12:49:41 -06:00
Lee Hinman 418eefbcf1 Remove BytesArray and BytesReference usage from XContentFactory (elastic/x-pack-elasticsearch#4158)
This is the x-pack side of https://github.com/elastic/elasticsearch/pull/29151

Original commit: elastic/x-pack-elasticsearch@be71338057
2018-03-20 11:52:31 -06:00
Alan Woodward c16e5f1f92 Watcher comparisons don't deal with NaN correctly (elastic/x-pack-elasticsearch#4133)
Aggregations may return `NaN`, and the comparison code would return `true` if this result was passed to a `gte` or `lte` condition.

Original commit: elastic/x-pack-elasticsearch@3b16ae6675
2018-03-20 15:55:59 +00:00
Alexander Reelsen 955b0dddad Watcher: Ignore deactivated state with execute watch API (elastic/x-pack-elasticsearch#4054)
If a watch is not active, it should still be executed, if it is called
via the execute watch API.

This commit adds an additional method to the execution context to check
for this, which returns true for a manual execution context but checks
the watch status for the triggered one.

Original commit: elastic/x-pack-elasticsearch@18f3f9e84b
2018-03-19 07:31:06 -07:00
Alexander Reelsen e53121206c Watcher: Clear usage stats when execution is paused (elastic/x-pack-elasticsearch#4132)
This ensures that the per watch stats in the trigger service are
properly cleared, when execution is paused.

Original commit: elastic/x-pack-elasticsearch@f5119e4072
2018-03-19 06:15:10 -07:00
Alexander Reelsen 92379ca9af Watcher: Ensure usage stats work properly in distributed environment (elastic/x-pack-elasticsearch#4094)
This adds back usage stats by pickybacking on the watcher stats, which
are already running distributed in order to collect and merge watcher
statistics.

In order to be able to track statistics, we need to add information for
each watch in an in-memory data structure that is processed whenever a
usage request is coming in. This processing creates a number of counters
for each node, which then are merged together in the usage stats.

relates elastic/x-pack-elasticsearch#4071

Original commit: elastic/x-pack-elasticsearch@c8bfed288f
2018-03-15 10:28:03 -07:00
Alexander Reelsen 4109f6e5b7 Watcher: Fix compilation issue
Original commit: elastic/x-pack-elasticsearch@d94d18a12f
2018-03-14 16:20:25 -07:00
Alexander Reelsen c30256e9b5 Watcher: Fix TransformInput toXContent serialization (elastic/x-pack-elasticsearch#4061)
The toXContent serialization of the transform input was broken, which
could lead to the bad case that a watch could be stored with an invalid
toXContent serialization, that could not be read again, when the watch
should either be executed or even just returned by the Get watch API.

relates elastic/x-pack-elasticsearch#4049

Original commit: elastic/x-pack-elasticsearch@f06ad768b8
2018-03-14 15:53:39 -07:00
Lee Hinman b14baf4a6f Decouple XContentBuilder from BytesReference (elastic/x-pack-elasticsearch#4119)
* Decouple XContentBuilder from BytesReference

This commit handles the removal of all mentions of BytesReference from
XContentBuilder. This is needed so that we can completely decouple the XContent
code and move it into its own dependency.

This is the x-pack side of https://github.com/elastic/elasticsearch/pull/28972

Original commit: elastic/x-pack-elasticsearch@8ba2e97b26
2018-03-14 13:48:05 -06:00
Lee Hinman 2147d217df Wrap stream passed to createParser in try-with-resources (elastic/x-pack-elasticsearch#4055)
This wraps the stream (`.streamInput()`) that is passed to many of the
`createParser` instances in the enclosing (or a new) try-with-resources block.
This ensures the `BytesReference.streamInput()` is closed.

Relates to elastic/x-pack-elasticsearch#28504

Original commit: elastic/x-pack-elasticsearch@7546e3b4d4
2018-03-04 16:48:15 -07:00
Lee Hinman c763a14132 Pass InputStream when creating XContent parser (elastic/x-pack-elasticsearch#4001)
* Pass InputStream when creating XContent parser

Rather than passing the raw `BytesReference` in when creating the xcontent
parser, this passes the StreamInput (which is an InputStream), this allows us to
decouple XContent from BytesReference.

This is the x-pack side of https://github.com/elastic/elasticsearch/pull/28754

* Use the streamInput variant, not sourceAsString

Original commit: elastic/x-pack-elasticsearch@dd5d8b1654
2018-02-23 15:22:28 -07:00
Alexander Reelsen 7f166e1927 Cleanup: Move tests calling external services into QA projects (elastic/x-pack-elasticsearch#3869)
This also moves the hipchat/pagerduty/slack tests to REST tests which put real watches and also check the history.

Relates elastic/x-pack-elasticsearch#3800


Original commit: elastic/x-pack-elasticsearch@fce08d9cb7
2018-02-23 13:31:28 +01:00
Alexander Reelsen 2ebb21f108 Watcher: Reduce threads on non-data nodes (elastic/x-pack-elasticsearch#3932)
The watcher thread pool is scaled by the number of CPUs and has by
default up to 5x the number of cores. This is needed because we assumme
I/O based waiting workloads for watcher. However if the node is not a
data node, there will not be any execution of watches with the exception
of a user calling the execute watch API on that node.

This means, we can get away with just one thread, so that there is no
need for the JVM to manage more threads on master/client or ingest only
nodes.

Original commit: elastic/x-pack-elasticsearch@b5899401d3
2018-02-23 09:16:32 +01:00
Alexander Reelsen 45fb3db062 Tests: Fix JiraIssueTests to not hide secrets
Original commit: elastic/x-pack-elasticsearch@f4c83c2da3
2018-02-23 09:10:56 +01:00
Luca Cavanna 79bc6d9a53 Remove AcknowledgedRestListener in favour of RestToXContentListener (elastic/x-pack-elasticsearch#3985)
Adapt to AcknowledgedRestListener removal 

Original commit: elastic/x-pack-elasticsearch@74c08fcf02
2018-02-22 09:13:58 +01:00
Alexander Reelsen 0bf354eb38 Watcher: Fix hipchat message failure serialization (elastic/x-pack-elasticsearch#3939)
The current toXContent serialization of a failed hipchat message writes
the same field called status twice and thus cannot be stored in the
watch history.

This commit ensures the field gets only written once.

relates elastic/x-pack-elasticsearch#3919

Original commit: elastic/x-pack-elasticsearch@fb499e8055
2018-02-21 09:38:53 +01:00
Lee Hinman 6728912c87 Handle removing log4j dependency from elasticsearch-core jar (elastic/x-pack-elasticsearch#3976)
This handles the removal of the log4j dependency from our elasticsearch-core
project. It was originally necessary only for our jar classpath checking. It is
now replaced by a `Consumer<String>`.

This is the x-pack side of https://github.com/elastic/elasticsearch/pull/28705

Original commit: elastic/x-pack-elasticsearch@1186a7eaf6
2018-02-20 09:15:56 -07:00
Alexander Reelsen c9d77d20fd Watcher: Never return credentials after watch creation... (elastic/x-pack-elasticsearch#3581)
... yet support updates. This commit introduces a few changes of how
watches are put.

The GET Watch API will never return credentials like basic auth
passwords, but a placeholder instead now. If the watcher is enabled to
encrypt sensitive settings, then the original encrypted value is
returned otherwise a "::es_redacted::" place holder.

There have been several Put Watch API changes.

The API now internally uses the Update API and versioning. This has
several implications. First if no version is supplied, we assume an
initial creation. This will work as before, however if a credential is
marked as redacted we will reject storing the watch, so users do not
accidentally store the wrong watch.

The watch xcontent parser now has an additional methods to tell the
caller if redacted passwords have been found. Based on this information
an error can be thrown.

If the user now wants to store a watch that contains a password marked
as redacted, this password will not be part of the toXContent
representation of the watch and in combinatination with update request
the existing password will be merged in. If the encrypted password is
supplied this one will be stored.

The serialization for GetWatchResponse/PutWatchRequest has changed.
The version checks for this will be put into the 6.x branch.

The Watcher UI now needs specify the version, when it wants to store a
watch. This also prevents last-write-wins scenarios and is the reason
why the put/get watch response now contains the internal version.

relates elastic/x-pack-elasticsearch#3089

Original commit: elastic/x-pack-elasticsearch@bb63be9f79
2018-02-20 10:09:27 +01:00
Tanguy Leroux eb11cb96a1 [Tests] Ensure that Watcher templates are created before creating alias (elastic/x-pack-elasticsearch#3956)
* [Tests] Ensure that Watcher templates are created before creating alias

The createWatcherIndicesOrAliases() method randomly created watcher
indices with or without aliases. On slow machines it is possible that
the indices get created before WatcherIndexTemplateRegistry put the
templates. When it happens, the indices will be created without the
right index.format value, preventing the WatcherService to start (as
it checks the index.format before starting, in case an upgrade is
required)

relates elastic/x-pack-elasticsearch#3965

Original commit: elastic/x-pack-elasticsearch@82946a2be0
2018-02-16 11:48:42 +01:00
Lee Hinman fbd9d6c7f5 Call createParser with deprecation handler (elastic/x-pack-elasticsearch#3943)
There are only two remaining callers from x-pack that don't pass the deprecation
handler in.

Relates to elastic/x-pack-elasticsearch#28504

Original commit: elastic/x-pack-elasticsearch@cb542613fd
2018-02-15 15:38:25 -07:00
Lee Hinman affc9e3563 Move more XContent.createParser calls to non-deprecated version (elastic/x-pack-elasticsearch#3928)
Part 2

This moves more of the callers to pass in the DeprecationHandler.

Relates to elastic/x-pack-elasticsearch#28504

Original commit: elastic/x-pack-elasticsearch@e0b52bf050
2018-02-14 09:41:26 -07:00
Alexander Reelsen 742c7001c9 Watcher: Ensure watcher service calls are properly caught (elastic/x-pack-elasticsearch#3906)
In order to prevent exceptions to bubble up to the thread pool exception
handler, this properly wraps all the calls for the watcher service
within an executor into an AbstractRunnable to catch and log a possible
exception.

relates elastic/x-pack-elasticsearch#3854

Original commit: elastic/x-pack-elasticsearch@c0b39e6b5b
2018-02-14 10:45:29 +01:00
Adrien Grand c633b919ab Watcher's ExecutionService is not thread-safe. (elastic/x-pack-elasticsearch#3861)
If start, stop and/or clearExecutions are called concurrently, you could end up
in an inconsistent state where `currentExecutions.sealAndAwaitEmpty` is called
twice on the same instance.

These `synchronized` keywords should make it a bit better, though I suspect
there are other issues and thread safety of this class should be reviewed.

This might have caused
https://internal-ci.elastic.co/job/elastic+x-pack-elasticsearch+5.6+multijob-unix-compatibility/932/consoleFull

Original commit: elastic/x-pack-elasticsearch@2f7e7a34d9
2018-02-13 11:27:11 +01:00
Tim Brooks 5dbbe8fef8 Default to basic license at startup (elastic/x-pack-elasticsearch#3878)
This is related to elastic/x-pack-elasticsearch#3877. This commit modifies the license settings to
default to self generating a basic license.

Original commit: elastic/x-pack-elasticsearch@cd6ee8e06f
2018-02-12 12:57:04 -07:00
Martijn van Groningen fde2adb1b3 increase watcher logging when delegating to trigger service
Original commit: elastic/x-pack-elasticsearch@448ee71f37
2018-02-12 16:12:50 +01:00
Alexander Reelsen d5281e89b7 Watcher: Register HTML sanitizer settings (elastic/x-pack-elasticsearch#3904)
The HTML sanitizer settings were not registered correctly, when the
grouping functionality was removed in elastic/x-pack-elasticsearch#3685

This registers the settings properly in watcher.

Relates elastic/support-dev-help-elasticsearch#413

Original commit: elastic/x-pack-elasticsearch@787bb3d9d3
2018-02-12 15:34:04 +01:00
Alexander Reelsen 54cb890eb7 Watcher: Allow to defer startup for tests (elastic/x-pack-elasticsearch#3903)
This commit introduces a new watcher setting to defer starting watcher
until it has been called with the API for the first time. This is
primarily useful in testing environments, as this ensures that watcher
does not try to reload itself because of starting first and then
creating watcher indices.

In addition the undocumented and unused option
xpack.watcher.start_immediately has been removed.

Relates elastic/x-pack-elasticsearch#3854

Original commit: elastic/x-pack-elasticsearch@2b55aec4ad
2018-02-12 14:24:05 +01:00
Alexander Reelsen 48f6a752cb Watcher: Fix proxy scheme to default to HTTP (elastic/x-pack-elasticsearch#3844)
This fixes a regression introduced in Elasticsearch 6.0, when switching
from HttpURLConnection to the Apache HTTP Client.

In the old implementation there was no way to specify if you wanted to use HTTP
or HTTPS for your proxy, only HTTP. If people needed to use HTTPs, they
could just use the CONNECT feature of the proxy.

The new implementation used the scheme of the request that was about to
be sent out as the proxy scheme to be used. So if the request was HTTPS
but the proxy server was HTTP this created a problem.

This commit changes the default scheme to be just HTTP, so that then the
standard CONNECT procecure is taken care off.

Without a real proxy server this is super hard to test. I have verified
this with the following test against a tinyproxy running on port 8888,
but I do not have a great idea how to test this in a unit testable way using a real proxy.

Original commit: elastic/x-pack-elasticsearch@f68e72d8f1
2018-02-12 13:12:38 +01:00
Alexander Reelsen f4fa274aa8 Tests: Do not set number of replicas for watcher index (elastic/x-pack-elasticsearch#3882)
The watcher index uses auto expanding of replicas nowadays, so there is
no need to set the number of replicas.

Also ensuring that all watcher indices are green on startup has been moved
to one call, in order to prevent indices being moved around after adding
the triggered watches or watch history index.

Original commit: elastic/x-pack-elasticsearch@dbe04adf64
2018-02-12 09:35:03 +01:00
Ryan Ernst 4e578fe7cc Build: Replace provided configuration with compileOnly (elastic/x-pack-elasticsearch#3868)
This is the xpack side of elastic/elasticsearch#28564

Original commit: elastic/x-pack-elasticsearch@60033824a4
2018-02-09 11:30:43 -08:00
Martijn van Groningen d2dc630e84 Changes required for elastic/elasticsearch#28588
Original commit: elastic/x-pack-elasticsearch@11d11c2d39
2018-02-09 17:14:30 +01:00
Lee Hinman dc833f2448 Remove all instances of the deprecated `ParseField.match` method (elastic/x-pack-elasticsearch#3874)
* Remove all instances of the deprecated `ParseField.match` method

This removes all the server references to the deprecated `ParseField.match`
method in favor of the method that passes in the deprecation logger.

Relates to https://github.com/elastic/elasticsearch/issues/28504

* Fix line-length

Original commit: elastic/x-pack-elasticsearch@e7cb2611f7
2018-02-09 09:01:18 -07:00
Alexander Reelsen 98e9365aa1 Tests: Increase logging for GetWatchTests
In order to get more insights into a specific test failure, that we
suppose to be in core, increase search logging to debug level.

Relates elastic/x-pack-elasticsearch#3854

Original commit: elastic/x-pack-elasticsearch@5c37535e03
2018-02-09 16:37:33 +01:00
Alexander Reelsen 064a0819d9 Cleanup: Remove HaltedClock (elastic/x-pack-elasticsearch#3731)
java.time features it's own halted clock, called a fixed clock, we can
use that one.

On top of that the watcher xcontent parser does not need a clock at all,
just a timestamp when parsing happened.

Original commit: elastic/x-pack-elasticsearch@2061aeffe1
2018-02-08 09:24:08 +01:00
Alexander Reelsen c20f3ba996 Watcher: Add support for scheme in proxy configuration (elastic/x-pack-elasticsearch#3614)
This adds support to allow different schemes in a proxy being used
compared to what the actual request requires. So if your proxy runs via
HTTP, but the endpoint you want to connect to uses HTTPS, this is now
possible to configure the proxy explicitely.

Also a small unit test for parsing this has been added.

relates elastic/x-pack-elasticsearch#3596

Original commit: elastic/x-pack-elasticsearch@176f7cdf0e
2018-01-31 14:12:25 +01:00
Alexander Reelsen 71f68d3413 Tests: Remove watcher ensureWachterStarted/Stopped methods (elastic/x-pack-elasticsearch#3798)
Tests have been failing because of out of order cluster state processing
or because of stopping/starting was still in progress. Current tests do
not do further stop/start tries after the first leading to potential
being stuck in an unwanted state. This commit removes the methods
checking for the state being started or stopped in favor of using the
stopWatcher/startWatcher methods which now check if the desired state is
reached and otherwise issue another start/stop command.

Original commit: elastic/x-pack-elasticsearch@97b3232a6a
2018-01-31 12:15:19 +01:00
Alexander Reelsen c65528b9f6 Watcher: Ensure state is cleaned properly in watcher life cycle service (elastic/x-pack-elasticsearch#3770)
The WatcherLifeCycleService is responsible for deciding if watches need
to be reloaded while running. In order to do this, the service stores
the currently local shard allocation ids in a List.

This data structure however was not properly updated all the time, when
it should have been - for example when a master node is not available.

This lead to unintended reloads, even though there was no change in the
allocated shards. This in turn lead to unwanted executions and unwanted
loading of triggered watches.

This commit should also fix one of the more nasty ongoing test failures,
where the test returns with an exception that only parts of watcher have
been started. The AbstractWatcherIntegrationTestCase now properly waits
until watcher is started before starting the test case itself.

Original commit: elastic/x-pack-elasticsearch@097f12a900
2018-01-30 10:28:48 +01:00
Ryan Ernst 5a86450df7 Build: Replace references to x-pack-elasticsearch paths with helper methods (elastic/x-pack-elasticsearch#3748)
In order to more easily integrate xpack once it moves into the
elasticsearch repo, references to the existing x-pack-elasticsearch need
to be reduced. This commit introduces a few helper "methods" available
to any project within xpack (through gradle project extension
properties, as closures). All refeerences to project paths now use these
helper methods, except for those pertaining to bwc, which will be
handled in a followup.

Original commit: elastic/x-pack-elasticsearch@850668744c
2018-01-26 21:48:30 -08:00
Alexander Reelsen 49ecd23eb9 Tests: Ensure watcher is stopped before restarting
The EmailSecretsIntegrationTests did not properly wait for watcher to be
stopped before starting it again.

This test failed a few times per week across master and 6.x branches.

Original commit: elastic/x-pack-elasticsearch@cf20d58b0b
2018-01-26 11:17:08 +01:00
Michael Basnight e59bcd8f8e Enable the licenseHeaders task for plugins (elastic/x-pack-elasticsearch#3673)
Original commit: elastic/x-pack-elasticsearch@c9949b8ca5
2018-01-25 11:34:02 -06:00
Michael Basnight 39b4587d02 Remove requiresKeystore when not actually required (elastic/x-pack-elasticsearch#3697)
Original commit: elastic/x-pack-elasticsearch@6bdd4ae2dc
2018-01-25 07:33:30 -06:00
Jim Ferenczi 3316c964c8 Move watcher's Cron into x-pack core (elastic/x-pack-elasticsearch#3716)
This change moves watcher's Cron class in the schedule package of xpack-core so that it can be used by other projects (rollup).

Original commit: elastic/x-pack-elasticsearch@f0aa32ccc2
2018-01-25 11:57:44 +01:00
Ryan Ernst 3e24ea3ed2 Test: Add internalClusterTest to xpack modules (elastic/x-pack-elasticsearch#3730)
This commit reenables running ITs in xpack by adding an internalClusterTest to xpack modules that contain ESIntegTestCase tests. The new task allows us to run these independently of rest integ tests, which are disabled for xpack modules because installing the bundled plugins directly is not quite the same as installing via the meta plugin. Some tests (ML) are moved to their own qa module to accommodate the need for a real cluster. A couple tests (monitoring and upgrade) have been marked as AwaitsFix.

Commits that have been folded into this commit:
* Move ML IT tests to qa/ml-native-tests
* Add internalClusterTest task and disable rest integ tests for xpack
modules. Also tweak ML tests and get upgrade tests working
* Adding the keystore and security back to the ml native tests
* Fixing native integ test
* Fix last ML test, add awaits fix to monitoring and upgrade tests
* cleanup PR
* fix checkstyle

Original commit: elastic/x-pack-elasticsearch@3c0ed6fd3b
2018-01-25 10:38:34 +01:00
Jason Tedor 3932635f98 Simplify security manager permissions
The security manager permissions were copied wholesale from pre-split
X-Pack. However, this grants unnecessary permissions to the child
plugins. This commit is a simple attempt at removing permissions that
are not needed in the child plugins.

Relates elastic/x-pack-elasticsearch#3651

Original commit: elastic/x-pack-elasticsearch@8325ed83d7
2018-01-24 08:57:54 -05:00
Simon Willnauer 3b7d1f4d98 Prevent watcher from starting after node has shutdown (elastic/x-pack-elasticsearch#3709)
Some tests seem to be pretty flaky due to concurrent watcher restarts.
This change makes sure we never restart watcher once the node is shutting down.

Original commit: elastic/x-pack-elasticsearch@f0bed7269b
2018-01-24 14:16:05 +01:00
Alexander Reelsen 1ebccfcf50 Settings: Cut over to affix settings where filters are needed (elastic/x-pack-elasticsearch#3685)
x-pack makes extensive use of group settings in its exporters as well as
its notification services. This does not cope well with settings being
marked as filtered.

This replaces a fair share of group settings (unfortunately not all of
them) with affix key settings, allowing for better filtering and
registering of settings.

Original commit: elastic/x-pack-elasticsearch@968bc8c2ee
2018-01-24 13:14:08 +01:00
Jason Tedor c0790d6a49 Move x-pack-core to core package (elastic/x-pack-elasticsearch#3678)
This commit moves the source file in x-pack-core to a org.elasticsearch.xpack.core package. This is to prevent issues where we have compile-time success reaching through packages that will cross module boundaries at runtime (due to being in different classloaders). By moving these to a separate package, we have compile-time safety. Follow-ups can consider build time checking that only this package is defined in x-pack-core, or sealing x-pack-core until modules arrive for us.

Original commit: elastic/x-pack-elasticsearch@232e156e0e
2018-01-23 12:43:58 -06:00
Alexander Reelsen d065b087ee Revert "Cleanup: Remove HaltedClock (elastic/x-pack-elasticsearch#3664)"
This reverts commit elastic/x-pack-elasticsearch@f91c401a60 due to
failing tests, like

./gradlew :x-pack-elasticsearch:plugin:watcher:test -Dtests.seed=AE30350FCE96D26D -Dtests.class=org.elasticsearch.xpack.watcher.watch.WatchTests -Dtests.method="testParserSelfGenerated" -Dtests.security.manager=true -Dtests.locale=ja-JP -Dtests.timezone=EET

Original commit: elastic/x-pack-elasticsearch@e45d79d643
2018-01-23 18:08:54 +01:00
Simon Willnauer 63c0e288af Ensure we protect Collections obtained from scripts from self-referencing (elastic/x-pack-elasticsearch#3681)
Self referencing maps can cause SOE if they are iterated ie. in their toString methods. This chance adds some protected to the usage of those collections.
see elastic/elasticsearch#28335

Original commit: elastic/x-pack-elasticsearch@c4f1089c74
2018-01-23 17:02:37 +01:00
Alexander Reelsen e3da8fa4ae Cleanup: Remove HaltedClock (elastic/x-pack-elasticsearch#3664)
The HaltedClock was a leftover from moving over from our own Clock
implementation to a java.time one. java.time already has a fixed clock,
this one is not needed.

Original commit: elastic/x-pack-elasticsearch@f91c401a60
2018-01-23 14:13:22 +01:00