Commit Graph

99 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
Przemko Robakowski 99c85f8e70
Fix disabling GeoIP downloader through elasticsearch.yml (#76924)
This change allows user to disable GeoIP downloader using elasticsearch.yml and it deletes .geoip_databases index if downloader is disabled.

Closes #76586
2021-08-26 08:47:37 +02:00
Przemko Robakowski bbfc6d2a45
Update licenses and attributions for GeoIP module (#75178)
Update licenses and attributions for GeoIP module
2021-07-26 14:16:14 +02:00
Przemko Robakowski b3ddec71f4
Add warning header after 25 days after last db update (#75311)
Add warning header after 25 days after last db update
2021-07-26 14:14:55 +02:00
Przemko Robakowski e245a80ac3
Mute GeoIpDownloaderIT#testInvalidTimestamp (#75398) 2021-07-15 18:56:48 -04:00
Przemko Robakowski 0f2e2213a8
Make GeoIpDownloaderIT.testInvalidTimestamp more robust (#75330)
This change adds additional assertion in GeoIpDownloaderIT.testInvalidTimestamp which makes sure that validity checks work both ways (so going out of validity and back) and it should fix race in cleanUp method leading to occasional failures.

Closes #75221
Closes #74358
2021-07-15 01:27:08 +02:00
Martijn van Groningen 9780f674ac
Improve stability of GeoIpDownloaderIT test suite. (#74558)
Adjust GeoIpDownloaderIT test suit to wait for managed databases files
to be removed after each test.

After each test geoip downloader is disabled,  which should eventually
remove the managed geoip database files. This happens in the background.
However a new test starts that assumes that the builtin databases are used
then that test can fail, because expected assertions will fail. The changes
in this commit should address this.

Closes #74358
2021-07-09 11:53:53 +02:00
Przemko Robakowski 04a9282994
Fix GeoIpProcessor when there's no updated db (#74944)
This change fixes problem with GeoIpProcessor when there's GeoIpTaskState present in the cluster state but there's no database matching the one used by the processor. It can happen when there are some but not all databases already updated.
2021-07-06 07:54:14 +02:00
Przemko Robakowski 9706d676a1
Enable GeoIP downloader by default (#74323)
This change will enable geoip downloader by default again. It also brings back relevant documentation.
2021-06-28 09:04:49 +02:00
Jay Modi d4afd6a216
Protect newly introduced system indices fully (#74186)
This change updates the way we handle net new system indices, which are
those that have been newly introduced and do not require any BWC
guarantees around non-system access. These indices will not be included
in wildcard expansions for user searches and operations. Direct access
to these indices will also not be allowed for user searches.

The first index of this type is the GeoIp index, which this change sets
the new flag on.

Closes #72572
2021-06-24 14:13:57 -04:00
David Kyle f5e0536e24
Mute GeoIpDownloaderIT testUseGeoIpProcessorWithDownloadedDBs (#74373)
For #74358
2021-06-21 16:40:15 +01:00
Przemko Robakowski 05d3316a76
Adjust serialisation versioning after ingest geoip processor change (#74328)
Adjust serialisation versioning now that: 'change GeoIP downloader policy after 30 days of no updates'  change has been back ported via #74296
2021-06-21 08:41:44 +02:00
Przemko Robakowski 331a44ba42
Change GeoIP downloader policy after 30 days of no updates (#74099)
This PR changes the way GeoIpDownloader and GeoIpProcessor handle situation when we are unable to update databases for 30 days. In that case:

GeoIpDownloader will delete all chunks from .geoip_databases index
DatabaseRegistry will delete all files on ingest nodes
GeoIpProcessor will tag document with tags: ["_geoip_expired_database"] field (same way as in Logstash)
This change also fixes bug with that breaks DatabaseRegistry and when it tires to download databases after updating timestamp only (GeoIpDownloader checks if there are new databases and updates timestamp because local databases are up to date)
2021-06-18 13:51:12 +02: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
Ryan Ernst f98b374cf6
Revert "Upgrade Azure SDK and Jackson (#72833) (#72995)" (#73837)
The recent upgrade of the Azure SDK has caused a few test failures that
have been difficult to debug and do not yet have a fix. In particular, a
change to the netty reactor resolving
(https://github.com/reactor/reactor-netty/issues/1655). We need to wait
for a fix for that issue, so this reverts commit
6c4c4a0ecb.

relates #73493
2021-06-07 10:20:46 -07:00
Ryan Ernst 6c4c4a0ecb
Upgrade Azure SDK and Jackson (#72833) (#72995)
This commit upgrades the Azure SDK to 12.11.0 and Jackson to 2.12.2. The
Jackson upgrade must happen at the same time due to Azure depending on
this new version of Jackson.

closes #66555
closes #67214

Co-authored-by: Francisco Fernández Castaño <francisco.fernandez.castano@gmail.com>
2021-05-27 07:55:18 -07:00
Przemko Robakowski a7ff5e7141
Disable GeoIP downloader (#72716)
Due to problems discovered in #72572 we have to disable geoip downloader for now. We use ingest.geoip.downloader.enabled.default as feature flag.
This change also reverts changes to docs.
2021-05-10 13:03:30 +02:00
Ryan Ernst 8cd3944a0a
Revert "Upgrade Azure SDK and Jackson (#72833)"
This reverts commit dca0e92bef.
2021-05-06 20:51:31 -07:00
Ryan Ernst dca0e92bef
Upgrade Azure SDK and Jackson (#72833)
This commit upgrades the Azure SDK to 12.11.0 and Jackson to 2.12.2. The
Jackson upgrade must happen at the same time due to Azure depending on
this new version of Jackson.

closes #66555
closes #67214
2021-05-06 20:36:42 -07:00
Przemko Robakowski 3130614196
Fail geoip processor if database is older than 30 days (#72367)
As required by MaxMind license we can't use databases that are older than 30 days as we could miss "don't sell" request.
This check was missing before and this change fixes that.
2021-04-28 22:12:00 +02:00
Przemko Robakowski e32a2f59b1
Hide .geoip_databases index (#72377)
Hidden index will no longer be target for wildcard (*) queries, this way we can avoid accidentally downloading huge amount of data
2021-04-28 16:18:02 +02:00
Martijn van Groningen 1c5272cc72
Adjust geoip downloader (#72094)
Instead of doing a refresh as part of each index request, perform
this separately after all chunks have been indexed.

Also perform a flush, so that the translog is trimmed and
doesn't contain all these large write operations (1mb) until
an automatic refresh happens (which may take a while since
no other indexing will take place for a while).
2021-04-23 09:07:28 +02:00
Przemko Robakowski 2b81d729be
Remove assertion from DatabaseRegistry (#71764)
This change removes assertion from DatabaseRegistry - we can easily loose .geoip_databases index with persistent task state still in cluster state, this is not assertion failing, this is usual failure and should be signalled as one.

This also tries to fix packaging tests by avoiding duplicates in elasticsearch.yml.

Closes #71762
2021-04-15 21:44:42 +02:00
Przemko Robakowski 308aee283d
Update GeoIP processor documentation (#71211)
This PR adds documentation for GeoIPv2 auto-update feature.
It also changes related settings names from geoip.downloader.* to ingest.geoip.downloader to have the same convention as current setting.

Relates to #68920

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2021-04-15 13:47:09 +02:00
Przemko Robakowski 39eb12a972
Enable GeoIP downloader by default (#71505)
This change enables GeoIP downloader by default.
It removes feature flag but adds flag that is used by tests to disable it again (as we don't want to hammer GeoIP database service with every test cluster we spin up).

Relates to #68920
2021-04-15 12:28:37 +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
Przemko Robakowski 46efa6ad04
Fix problems in GeoIPv2 code (#71598)
This change fixes number of problems in GeoIPv2 code:

- closes streams from Files.list in GeoIpCli, which should fix tests on Windows
- makes sure that total download time in GeoIP stats is non-negative (we serialize it as vInt which can cause problems with negative numbers and it can happen when clock was changed during operation)
- fixes handling of failed/simultaneous downloads, #69951 was meant as a way to prevent 2 persistent tasks to index chunks but it would prevent any update if single download failed mid indexing, this change uses timestamp (lastUpdate) as sort of UUID. This should still prevent 2 tasks to step on each other toes (overwriting chunks) but in the end still only single task should be able to update task state (this is handled by persistent tasks framework)
Closes #71145
2021-04-13 17:10:45 +02:00
Martijn van Groningen a478b5ff72
Fix GeoIpProcessorNonIngestNodeIT#testLazyLoading(...) (#71579)
Ensure that the index request is routed to the ingest,
so that the lazy loading occurs of geoip database
on ingest node (which is what is asserted later on)
Otherwise the database is lazy loaded on a different node.

(without this fix, this test fails reproducible with
`-Dtests.seed=2E234CC71CE96F4F`)

Closes #71251
2021-04-13 10:01:52 +02:00
Przemko Robakowski 44a2ae4893
Add GeoIP CLI integration test (#71381)
This change adds additional test to GeoIpDownloaderIT which tests that artifacts produces by GeoIP CLI tool can be consumed by cluster the same way as from our original service.
It does so by running the tool from fixture which then simply serves the generated files (this is exactly the way users are supposed to use the tool as well).

Relates to #68920
2021-04-08 12:49:29 +02:00
Benjamin Trent 9b1ef4982d
Muting test for issue #71251 (#71253) 2021-04-02 13:39:30 -04:00
Jake Landis 279fde375e
Apply REST API compatibility testing for the :modules (#71137) 2021-04-02 11:20:54 -05:00
Jason Tedor 32314493a2
Pass override settings when creating test cluster (#71203)
Today when creating an internal test cluster, we allow the test to
supply the node settings that are applied. The extension point to
provide these settings has a single integer parameter, indicating the
index (zero-based) of the node being constructed. This allows the test
to make some decisions about the settings to return, but it is too
simplistic. For example, imagine a test that wants to provide a setting,
but some values for that setting are not valid on non-data nodes. Since
the only information the test has about the node being constructed is
its index, it does not have sufficient information to determine if the
node being constructed is a non-data node or not, since this is done by
the test framework externally by overriding the final settings with
specific settings that dicate the roles of the node. This commit changes
the test framework so that the test has information about what settings
are going to be overriden by the test framework after the test provide
its test-specific settings. This allows the test to make informed
decisions about what values it can return to the test framework.
2021-04-02 10:20:36 -04:00
Przemko Robakowski 61fe14565a
Add tool for preparing local GeoIp database service (#71018)
Air-gapped environments can't simply use GeoIp database service provided by Infra, so they have to either use proxy or recreate similar service themselves.
This PR adds tool to make this process easier. Basic workflow is:

download databases from MaxMind site to single directory (either .mmdb files or gzipped tarballs with .tgz suffix)
run the tool with $ES_PATH/bin/elasticsearch-geoip -s directory/to/use [-t target/directory]
serve static files from that directory (for example with docker run -v directory/to/use:/usr/share/nginx/html:ro nginx
use server above as endpoint for GeoIpDownloader (geoip.downloader.endpoint setting)
to update new databases simply put new files in directory and run the tool again
This change also adds support for relative paths in overview json because the cli tool doesn't know about the address it would be served under.

Relates to #68920
2021-03-31 12:30:21 +02:00
Przemko Robakowski f1feece422
Fix DatabaseRegistry for Windows (#71008)
In DatabaseRegistry we tried to replace file that was still open. This is not a problem under Linux and MacOS but Windows doesn't like it.
It was caught by our CI with reproducible failures when WindowsFS was set up by Lucene.
Now we skip one temp file and use GzipInputStream directly which fixes this problem.

Marking as non-issue since the code was not released yet.

Closes #70977
Closes #71006
2021-03-29 23:57:57 +02:00
Mark Vieira d407a9699e Mute DatabaseRegistryTests.testCheckDatabases 2021-03-29 11:12:50 -07:00
Przemko Robakowski b025f51ece
Add support for .tgz files in GeoIpDownloader (#70725)
We have to ship COPYRIGHT.txt and LICENSE.txt files alongside .mmdb files for legal compliance. Infra will pack these in single .tgz (gzipped tar) archive provided by GeoIP databases service.
This change adds support for that format to GeoIpDownloader and DatabaseRegistry
2021-03-29 12:46:27 +02:00
Mark Vieira 6339691fe3
Consolidate REST API specifications and publish under Apache 2.0 license (#70036) 2021-03-26 16:20:14 -07:00
Martijn van Groningen be38621ab3
Improve GeoIpDownloaderIT test case (#70640)
GeoIpDownloaderIT should be able to reuse test clusters and
run tests against a test cluster with multiple nodes.
2021-03-24 13:58:46 +01:00
Przemko Robakowski 11bd61d059
Fix GeoIpDownloaderStatsIT.testStats (#70809)
Node in GeoIpStats response can have no databases field if there are no databases yet downloaded to that node. We have to check if the key is there before processing it to avoid NPE.

Fixes #70789
2021-03-24 13:37:33 +01:00
Przemko Robakowski f5b7aad8b7
Add stats endpoint to GeoIpDownloader (#70282)
This change adds _geoip/stats endpoint that can be used to collect basic data about geoip downloader (successful, failed and skipped downloads, current db count and total time spent downloading).
It also fixes missing/wrong origins for clients that will break if used with security.

Relates to #68920
2021-03-23 14:34:32 +01:00
Martijn van Groningen 3d3ec5c4fe
Take the node id into account when creating geoip tmp dir. (#70462)
This change adjust where the geoip tmp directory is created
to avoid issues when running multiple nodes on the same machine.

In the java tmp dir, a 'geoip-databases' directory is created and
directly under this directory a directory with the node id as name is created.
This allows safely running multiple nodes on the same machine (this
happens mainly during tests).

Closes #69972
Relates to #68920
2021-03-17 13:20:56 +01:00
Przemko Robakowski 1787d7f988
Make GeoIp tests more robust (#70305)
This change modifies GeoIpDownloaderIT to wait in assertBusy despite of error (by wrapping whole body in try-catch) and adds additional assertion to debug failures tracked in #69594
2021-03-11 13:02:23 +01:00
Martijn van Groningen 9b0ee0d14f
Muted GeoIpDownloaderIT#testUseGeoIpProcessorWithDownloadedDBs(...) test,
see #69972
2021-03-10 14:13:01 +01:00
Martijn van Groningen 71c3854d76
Fix GeoIpDownloaderIT#testUseGeoIpProcessorWithDownloadedDBs(...) test (#70215)
The test failure looks legit, because there is a possibility that the same databases
was downloaded twice. See added comment in DatabaseRegistry class.

Relates to #69972
2021-03-10 13:30:25 +01:00
Martijn van Groningen 0c82c4c789
Fix DatabaseRegistryTests (#70180)
This test predefined expected md5 hashes in constants, that were expected with java15.
However java16 creates different md5 hashes and so the expected md5 hashes don't match
with the actual md5 hashes, which caused tests in this test suite to fail (running
with java16 only).

The tests now generates the expected md5 hash during the test instead of using predefined constants.

Closes #69986
2021-03-10 11:37:05 +01:00
Martijn van Groningen e3a375e279
Fix ReloadingDatabasesWhilePerformingGeoLookupsIT (#70163)
Wait for ingest threads to stop using the DatabaseReaderLazyLoader, so the during the next run the db update thread doesn't try to remove the db again (because the file hasn't yet been deleted).

Also delete tmp dirs this test create at the end of the test, so that when repeating this test many times, this test doesn't accumulate many directories with database files.

Closes #69980
2021-03-09 21:13:32 +01:00
Przemko Robakowski 2950308be9
Fix clean up of old entries in DatabaseRegistry.initialize (#70135)
This change switches clean up in DatabaseRegistry.initialize from using Files.walk and stream operations to Files.walkFileTree which can be made more robust in case of errors
2021-03-09 13:54:45 +01:00
Przemko Robakowski dec44d067b
Fix GeoIpDwonloaderExecutor.setEnabled (#70111)
When geoip.downloader.enabled setting changes we should try to start/stop geo ip task from single node only- other requests will definitely fail.
This change also extends timeout in GeoIpDownloaderIT as current short one fails sometimes in CI
2021-03-08 22:28:41 +01:00
Martijn van Groningen 22c63aa711
Muted a few DatabaseRegistryTests tests, see #69986 2021-03-04 19:03:00 +01:00