Commit Graph

244 Commits

Author SHA1 Message Date
Rene Groeschke 35ec6f348c
Introduce simple public yaml-rest-test plugin (#76554)
This introduces a basic public yaml rest test plugin that is supposed to be used by external 
elasticsearch plugin authors. This is driven by #76215

- Rename yaml-rest-test to intern-yaml-rest-test
- Use public yaml plugin in example plugins

Co-authored-by: Mark Vieira <portugee@gmail.com>
2021-08-31 08:45:52 +02:00
Mark Tozzi d715449766
Apply spotless to aggregations (#76682)
* spotless apply for core analytics code

* spotless apply for x-pack:plugin:analytics

* spotless apply for matrix stats

* don't format huge lists of HLL constants

* Spotless for Rollups

* Don't exclude HLLPP, we added narrower inline exclusions
2021-08-30 13:42:20 -04:00
Rory Hunter d01efa4fd6
Changes to keep Checkstyle happy after reformatting (#76464)
* Reformatting to keep Checkstyle after formatting

* Configure spotless everywhere, and disable the tasks if necessary

* Add XContentBuilder helpers, fix test

* Tweaks

* Add a TODO

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-08-18 07:15:55 -04:00
Hendrik Muhs fb0846a23d
[Transform][Rollup] remove unnecessary list indirection (#75459)
Remove an unnecessary indirection and refactor progress tracking. Both rollup and transform
process documents as stream, however in the AsyncTwoPhaseIndexer takes a List of index
requests. This change removes the unnecessary temporary container and makes upcoming
transform enhancements easier.
2021-07-28 16:34:17 +02:00
Mark Tozzi 7af39dbc35
Remove deprecated date histo interval (#75000)
Date histogram interval parameter was deprecated in 7.2, in favor of the more specific fixed_interval and calendar_interval parameters.  The old logic used some poorly understood guessing to decide if it should operate in fixed or calendar mode.  The new logic requires a specific choice by the user, which is more explicit.  In 7.x REST compatibility mode, we will parse the interval as calendar if possible, and otherwise interpret it as fixed.
2021-07-20 13:08:45 -04:00
Christoph Büscher 9b15e1a04a
Change XExternalRefSorter class header (#74680)
This change makes the class header only contain the Apache license part like we
do in similar cases where we have copied code from Lucene to our repo (see e.g.
the XMoreLikeThis header)
2021-06-30 10:50:20 +02:00
Rene Groeschke c59ea7971b
Introduce ElasticsearchJavaBasePlugin to simplify YamlRestTestPlugin (#74411)
just configuring common conventions on java based projects without
adding opinionated sourcesets. Reduces the configuration overhead for
yaml rest test only projects.

In the end we create less tasks and configure less for test only projects.
2021-06-23 11:36:58 +02:00
Joe Gallo 1911d33579
Resurrect _xpack/rollup routes (#73977) 2021-06-10 08:58:03 -04:00
Ryan Ernst 63012c8a40
Move ParseField to o.e.c.xcontent (#73923)
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
2021-06-08 13:32:14 -07:00
Ryan Ernst 68817d7ca2
Rename o.e.common in libs/core to o.e.core (#73909)
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
2021-06-08 09:53:28 -07:00
Rene Groeschke e609e07cfe
Remove internal build logic from public build tool plugins (#72470)
Extract usage of internal API from TestClustersPlugin and PluginBuildPlugin and related plugins and build logic

This includes a refactoring of ElasticsearchDistribution to handle types
better in a way we can differentiate between supported Elasticsearch
Distribution types supported in TestCkustersPlugin and types only supported
in internal plugins.

It also introduces a set of internal versions of public plugins.

As part of this we also generate the plugin descriptors now.

As a follow up on this we can actually move these public used classes into 
an extra project (declared as included build)

We keep LoggedExec and VersionProperties effectively public And workaround for RestTestBase
2021-05-06 14:02:35 +02:00
Rene Groeschke 5bcd02cb4d
Restructure build tools java packages (#72030)
Related to #71593 we move all build logic that is for elasticsearch build only into
the org.elasticsearch.gradle.internal* packages

This makes it clearer if build logic is considered to be used by external projects
Ultimately we want to only expose TestCluster and PluginBuildPlugin logic
to third party plugin authors.

This is a very first step towards that direction.
2021-04-26 14:53:55 +02:00
Lyudmila Fokina 3b0b7941ae
Warn users if security is implicitly disabled (#70114)
* Warn users if security is implicitly disabled

Elasticsearch has security features implicitly disabled by default for
Basic and Trial licenses, unless explicitly set in the configuration
file.
This may be good for onboarding, but it also lead to unintended insecure
 clusters.
 This change introduces clear warnings when security features are
 implicitly disabled.
 - a warning header in each REST response if security is implicitly
 disabled;
 - a log message during cluster boot.
2021-04-13 18:33:41 +02:00
Luca Cavanna 1469e18c98
Add support for script parameter to boolean field mapper (#71454)
Relates to #68984
2021-04-12 10:04:12 +02:00
Joe Gallo 2a0ec50d47
Apply REST API compatibility testing for the :x-pack plugins (#71302) 2021-04-06 11:35:33 -04:00
Alan Woodward 1653f2fe91
Add script parameter to long and double field mappers (#69531)
This commit adds a script parameter to long and double fields that makes
it possible to calculate a value for these fields at index time. It uses the same
script context as the equivalent runtime fields, and allows for multiple index-time
scripted fields to cross-refer while still checking for indirection loops.
2021-03-31 11:14:11 +01:00
Mark Vieira 6339691fe3
Consolidate REST API specifications and publish under Apache 2.0 license (#70036) 2021-03-26 16:20:14 -07:00
Tal Levy 42cb9d0756
mute RollupActionSingleNodeTests (#70582) 2021-03-18 13:18:38 -07:00
Tal Levy 259ca47917
Unmute RollupActionSingleNodeTests (#70519)
this commit unmutes the tests so that more CI runs with
new code that includes better error messages will highlight why
tests are flaky.

relates #69506, #69799, #69733.
2021-03-18 08:08:31 -07:00
Armin Braun b6a369858d
Cleanup more ActionListener Delegation Spots (#69662)
Cleaning up the remaining spots where the short-wrapper methods
could be used that I could find.
2021-03-16 08:47:37 +01:00
Christos Soulios cdb302cdf1
[RollupV2] Move rollup metadata to field mappings (#69921)
This PR moves field related rollup metadata from the index metadata to the field mapping metadata.

- date_histogram fields is moved to the timestamp field 
     (fields are fixed_interval or calendar_interval, time_zone)
- histogram fields are moved to the numeric field on which the the histogram is computed 
     (the field is named interval)

Also, the index uuid has been added to the index rollup settings as index.rollup.source.uuid 
and index.rollup.source.name

The rest of the RollupMetadata has been removed and no rollup metadata exists in the global 
cluster state.

Co-authored-by: Tal Levy <jubboy333@gmail.com>
2021-03-11 11:25:12 +02:00
Tal Levy 6eda84a487
Add rollup config validation (#69582)
The RollupActionConfig objects had validation of mappings, but
the TransportRollupAction never leveraged them to validate the
action. This commit introduces a new first step for validation
before continuing with the rollup.

validation exception messages had "... across all indices" removed
from the messages of RollupAction objects, but legacy objects were
left untouched since they still interact with index patterns and
RollupAction is always against one index.
2021-03-05 10:58:24 -08:00
David Turner 864ff66f68
Unique names for bulk processor scheduler threads (#69432)
Today every `BulkProcessor` creates two scheduler threads, both called
`[node-name][scheduler][T#1]`, which is also the name of the main
scheduler thread for the node. The duplicated thread names make it
harder to interpret a thread dump.

This commit makes the names of these threads distinct.

Closes #68470
2021-03-04 12:05:24 +00:00
Nik Everett 10e2f90560
Speed up aggs with sub-aggregations (#69806)
This allows many of the optimizations added in #63643 and #68871 to run
on aggregations with sub-aggregations. This should:
* Speed up `terms` aggregations on fields with less than 1000 values that
  also have sub-aggregations. Locally I see 2 second searches run in 1.2
  seconds.
* Applies that same speedup to `range` and `date_histogram` aggregations but
  it feels less impressive because the point range queries are a little
  slower to get up and go.
* Massively speed up `filters` aggregations with sub-aggregations that
  don't have a `parent` aggregation or collect "other" buckets. Also
  save a ton of memory while collecting them.
2021-03-03 18:04:47 -05:00
David Turner 2eb1f92bf2 Mute RollupActionSingleNodeTests
Relates #69799
2021-03-02 13:18:44 +00:00
David Turner c95a6afa21 Mute RollupActionSingleNodeTests#testRollupShardIndexerCleansTempFiles
Relates #69506
2021-03-02 12:01:07 +00:00
Tal Levy c1c5103756
Generate random rollup index names for RollupILMAction (#69237)
This commit moves away from the static `rollup-{indexName}` rollup index
naming strategy and moves towards a randomized rollup index name scheme.

This will reduce the complications that exist if the RollupStep fails and retries
in any way. A separate cleanup will still be required for failed temporary indices,
but at least there will not be a conflict.

This commit generates the new rollup index name in the LifecycleExecutionState so
that it can be used in RollupStep and UpdateRollupIndexPolicyStep on a per-index
basis.
2021-02-24 12:31:36 -08:00
Tal Levy 312ed43d7c
mute testTemporaryIndexDeletedOnRollupFailure (#69558)
this commit mutes a test that fails once in a while:
RollupActionSingleNodeTests.testTemporaryIndexDeletedOnRollupFailure
2021-02-24 08:32:49 -08:00
Nik Everett f2d6c25732
Allow terms to run as filters (#68871)
This adds yet another terms aggregator that uses `term` filters to run
in similar speed to specialized low cardinality terms aggregator. It is
mostly useful as a stepping stone for some additional optimizations that
we can make later. So it doesn't have to be faster on its own. Just not
*slower*. And its about the same speed.
2021-02-19 17:16:24 -05:00
Rene Groeschke bdf229a148
Introduce Internal Test Artifact Plugin (#68766)
This reduces the ceremony declaring test artifacts for a project.
It also solves an issue with usage of deprecated testRuntime that
testArtifacts extendsFrom which seems not required at all and would have
broke with Gradle 7.0 anyhow

Test artifact resolution is now variant aware which allows us a more adequate 
compile and runtime classpath for the consuming projects.

We also Introduce a convention method in the elasticsearch build to declare 
test artifact dependencies in an easy way close to how its done by the gradle build in 
test fixture plugin.

Furthermore we cleaned up some inconsistent test dependencies declarations when 
relying on a project and on its test artifacts
2021-02-16 14:36:17 +01:00
Alan Woodward dbff7bea37
Rename DocValueFetcher.Leaf to FormattedDocValues (#68818)
Also moves it to a top-level interface in fielddata. It is not only used by
DocValueFetcher any more, and Leaf does not really describe what
it does or what it provides.
2021-02-15 10:03:25 +00:00
Tal Levy a0d8a8958e
Fixes assertion check in RollupShardIndexer (#68878)
This commit removes the assertion in RollupShardIndexer that verifies that
temporary files are deleted. Since it is the responsibility of the indexer
to instruct the OS to delete files, it may not do so in a timely manner. This
results in a potentially flaky assertion. Instead, a new unit test is introduced
that will introspect the indexer and assert that it had successfully called
for the files to be deleted.

Closes #68609.
2021-02-11 15:06:57 -08:00
Igor Motov 0bbc6addd9
Revert "Remove aggregation's postCollect phase (#68615)
This partially reverts #64016 and  and adds #67839 and adds
additional tests that would have caught issues with the changes
in #64016. It's mostly Nik's code, I am just cleaning things up
a bit.

Co-authored-by: Nik Everett <nik9000@gmail.com>
2021-02-10 19:12:50 -05:00
Rory Hunter 9c7fe876a2
Replace NOT operator with explicit `false` check - part 10 (#68652)
Part 10 (and hopefully the last one).

We have an in-house rule to compare explicitly against `false` instead
of using the logical not operator (`!`). However, this hasn't
historically been enforced, meaning that there are many violations in
the source at present.

We now have a Checkstyle rule that can detect these cases, but before we
can turn it on, we need to fix the existing violations. This is being
done over a series of PRs, since there are a lot to fix.
2021-02-08 15:38:22 +00:00
Rene Groeschke 5dfa6f46ac
Remove deprecated usage of default configuration (#68575)
This has been deprecated in gradle before but we havnt been warned.

Gradle 7.0 will likely introduce a change in behaviour here that we
should fix the usage of this configuration upfront.

See https://github.com/gradle/gradle/issues/16027 for further information
about the change in Gradle 7.0
2021-02-07 12:08:02 +01:00
Tal Levy 7ecb716622
Make RollupAction a master-node-action (#68420)
this commit moves most of the coordination of setting up a rollup index
to the master node RollupAction. The indexing and broadcast action,
RollupIndexerAction, was created and split out as its own action to handle
indexing into the rollup index.

Closes #68296.
2021-02-03 19:33:43 -08:00
Mark Vieira a92a647b9f Update sources with new SSPL+Elastic-2.0 license headers
As per the new licensing change for Elasticsearch and Kibana this commit
moves existing Apache 2.0 licensed source code to the new dual license
SSPL+Elastic license 2.0. In addition, existing x-pack code now uses
the new version 2.0 of the Elastic license. Full changes include:

 - Updating LICENSE and NOTICE files throughout the code base, as well
   as those packaged in our published artifacts
 - Update IDE integration to now use the new license header on newly
   created source files
 - Remove references to the "OSS" distribution from our documentation
 - Update build time verification checks to no longer allow Apache 2.0
   license header in Elasticsearch source code
 - Replace all existing Apache 2.0 license headers for non-xpack code
   with updated header (vendored code with Apache 2.0 headers obviously
   remains the same).
 - Replace all Elastic license 1.0 headers with new 2.0 header in xpack.
2021-02-02 16:10:53 -08:00
Rory Hunter b4514228f0
Replace NOT operator with explicit `false` check - part 5 (#68360)
Part 5.

We have an in-house rule to compare explicitly against `false` instead
of using the logical not operator (`!`). However, this hasn't
historically been enforced, meaning that there are many violations in
the source at present.

We now have a Checkstyle rule that can detect these cases, but before we
can turn it on, we need to fix the existing violations. This is being
done over a series of PRs, since there are a lot to fix.
2021-02-02 14:27:33 +00:00
Tal Levy 70c611ba66
Refactor RollupAction to leverage a shard-based indexing strategy (#66423)
This commit refactors the rollup action in order to execute on a per shard basis.
Each shard is responsible for sending its local buckets to the target rollup index.
The shard action is executed in the rollup thread pool in order to limit the
number of shards that can rollup concurrently per node.
Buckets are computed on the fly using the index searcher and they are sorted
using a compressed offline sorter.

This commit also removes the rollup thread pool usage in the RollupAsyncIndexer that is used by
the legacy rollup and transforms. All actions performed by this indexer are asynchronous so
using the generic thread pool to fire search and bulk requests is ok.

Co-authored-by: jimczi <jim.ferenczi@elastic.co>
Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2021-01-21 13:21:06 -08:00
Rory Hunter 1a05a5ac24
Introduce deprecation categories (#67443)
Closes #64824. Introduce the concept of categories to deprecation
logging. Every location where we log a deprecation message must now
include a deprecation category.
2021-01-18 16:16:54 +00:00
gf2121 92f85981a7
Avoid duplicate serialization for TermsQueryBuilder (#67223)
Avoid duplicate serialization for TermsQuery.
2021-01-18 09:04:29 +01:00
Julie Tibshirani 5852fbedf5
Rename QueryShardContext -> SearchExecutionContext. (#67490)
We decided to rename `QueryShardContext` to clarify that it supports all parts
of search request execution. Before there was confusion over whether it should
only be used for building queries, or maybe only used in the query phase. This
PR also updates the javadocs.

Closes #64740.
2021-01-14 09:11:59 -08:00
Nik Everett 3052ab8dc2
Drop BigArrays from QueryShardContext (#66945)
It's only used in aggs land and aggs have their own easy way to get it.
2021-01-13 13:34:12 -05:00
Tal Levy 668488e3e1
Update Rollup's QA/rest to use yaml-rest-test plugin in build (#67303)
This commit updates the Rollup qa directory to leverage the
updated convention of running yaml tests. This also fixes a bug
wherein the qa tests were not running on `rollup:check`.
2021-01-12 10:05:44 -08:00
Ryan Ernst 495d29fcc4
Remove empty policy file (#66657)
There was once a packaging test that enforced all xpack modules had a
policy file, but that check no longer exists.
2021-01-04 16:08:56 -08:00
Tal Levy 53ed3a7a44
Create new dedicated Rollup Action Group Config (#66714)
This commit migrates RollupAction away from using the
legacy Rollup's GroupConfig and DateHistogramGroupConfig
classes. RollupAction is not concerned with legacy intervals
and delays.
2021-01-04 11:21:30 -08:00
Ioannis Kakavas bd873698bc
Ensure CI is run in FIPS 140 approved only mode (#64024)
We were depending on the BouncyCastle FIPS own mechanics to set
itself in approved only mode since we run with the Security
Manager enabled. The check during startup seems to happen before we
set our restrictive SecurityManager though in
org.elasticsearch.bootstrap.Elasticsearch , and this means that
BCFIPS would not be in approved only mode, unless explicitly
configured so.

This commit sets the appropriate JVM property to explicitly set
BCFIPS in approved only mode in CI and adds tests to ensure that we
will be running with BCFIPS in approved only mode when we expect to.
It also sets xpack.security.fips_mode.enabled to true for all test clusters
used in fips mode and sets the distribution to the default one. It adds a
password to the elasticsearch keystore for all test clusters that run in fips
mode.
Moreover, it changes a few unit tests where we would use bcrypt even in
FIPS 140 mode. These would still pass since we are bundling our own
bcrypt implementation, but are now changed to use FIPS 140 approved
algorithms instead for better coverage.

It also addresses a number of tests that would fail in approved only mode
Mainly:

    Tests that use PBKDF2 with a password less than 112 bits (14char). We
    elected to change the passwords used everywhere to be at least 14
    characters long instead of mandating
    the use of pbkdf2_stretch because both pbkdf2 and
    pbkdf2_stretch are supported and allowed in fips mode and it makes sense
    to test with both. We could possibly figure out the password algorithm used
    for each test and adjust password length accordingly only for pbkdf2 but
    there is little value in that. It's good practice to use strong passwords so if
    our docs and tests use longer passwords, then it's for the best. The approach
    is brittle as there is no guarantee that the next test that will be added won't
    use a short password, so we add some testing documentation too.
    This leaves us with a possible coverage gap since we do support passwords
    as short as 6 characters but we only test with > 14 chars but the
    validation itself was not tested even before. Tests can be added in a followup,
    outside of fips related context.

    Tests that use a PKCS12 keystore and were not already muted.

    Tests that depend on running test clusters with a basic license or
    using the OSS distribution as FIPS 140 support is not available in
    neither of these.

Finally, it adds some information around FIPS 140 testing in our testing
documentation reference so that developers can hopefully keep in
mind fips 140 related intricacies when writing/changing docs.
2020-12-23 21:00:49 +02:00
Nik Everett 3e3152406a
Bust the request cache when the mapping changes (#66295)
This makes sure that we only serve a hit from the request cache if it
was build using the same mapping and that the same mapping is used for
the entire "query phase" of the search.

Closes #62033
2020-12-23 13:19:02 -05:00
Jim Ferenczi c756ce1acf
Sort field tiebreaker for PIT (point in time) readers (#66093)
This commit introduces a new sort field called `_shard_doc` that
can be used in conjunction with a PIT to consistently tiebreak
identical sort values. The sort value is a numeric long that is
composed of the ordinal of the shard (assigned by the coordinating node)
and the internal Lucene document ID. These two values are consistent within
a PIT so this sort criteria can be used as the tiebreaker of any search
requests.
Since this sort criteria is stable we'd like to add it automatically to any
sorted search requests that use a PIT but we also need to expose it explicitly
in order to be able to:
* Reverse the order of the tiebreaking, useful to search "before" `search_after`.
* Force the primary sort to use it in order to benefit from the `search_after` optimization when sorting by index order (to be released in Lucene 8.8.

I plan to add the documentation and the automatic configuration for PIT in a follow up since this change is already big.

Relates #56828
2020-12-18 12:13:12 +01:00
Ryan Ernst d38e5e0d4b
Remove basic feature checks from license state (#59814)
The XPackLicenseState is a utility to handle checking the currently
configured license level against the required license level of each
licensed feature. Originally all licensed features were paid features
and licenses always had a limited time scope. However, since the basic
license was introduced, all users have an unlimited time use of basic
features; there is no actual "basic license", rather it is the base case
for the default distribution. Therefore, the checks on basic features in
license state are no-ops because the current license always at least
allows basic features, and the basic license cannot be expired.

This commit removes all of the features from the license state marked as
BASIC or MISSING (a level lower than BASIC that also predates the basic
license and is no longer relevant). It also adds an assertion that no
basic license features can be added to the license state in the future.
2020-12-17 20:48:05 -08:00