Commit Graph

130 Commits

Author SHA1 Message Date
Rory Hunter 577010740e
Allow container restarts with file logging (#73101)
Closes #72702. It wasn't possible to restart an Elasticsearch Docker
container when using `ES_LOG_STYLE=file`, and now it is.
2021-05-14 20:40:27 +01:00
Mark Vieira 6104438d6b
Fixes for package upgrade tests for versions prior to 7.7 (#72430) 2021-04-28 16:41:38 -07:00
Mark Vieira b818831c7e
Fixes for packaging upgrade tests (#72420) 2021-04-28 14:21:01 -07: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
Przemko Robakowski 4578a933b8
Disable GeoIP downloader in packaging tests (#71884)
This change disables geoip downloader in install command of packaging tests to catch all usage.

Closes #71848
2021-04-20 18:15:39 +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
Rory Hunter de24331e6b
Upgrade Spotless from 5.9.0 to 5.12.0 (#71561)
Upgrade Spotless from 5.9.0 to 5.12.0. This causes a few formatting changes around
how lambdas are arranged, mostly for the better.
2021-04-12 19:34:44 +01:00
Mark Vieira 5477626442
Use latest busybox musl binaries for Docker distribution (#71199) 2021-04-06 09:08:11 -07:00
Yash Jipkate 60f4d22722
Change default value of `action.destructive_requires_name` to True. (#66908)
This PR sets the default value of `action.destructive_requires_name`
to `true.` Fixes #61074. Additionally, we set this value explicitly in
test classes that rely on wildcard deletions to clear test state.
2021-03-31 15:59:57 -04:00
Rory Hunter 1c5b7653f0
Build Docker images from exported contexts and test them (#70088)
Closes #69930. Closes #69928.

The ES build currently has 2 types of Docker output - Docker images,
and Docker build contexts. At the moment, only the images are tested,
meaning that bugs in the build contexts can go unnoticed.

This PR changes how we create Docker images so that we first create
the build contexts, and then build the images using them. This does
require some sleight-of-hand - the build contexts expect to download
an Elasticsearch archive directorly from the `Dockerfile`, which
will only ever work for non-snapshot version builds. In order to
get around this, the `Dockerfile` is modified to `COPY` in a local
archive file. Any other dependency files must exist in the build
context archive.

This PR also builds and tests the Iron Bank context. We do not
currently build a Docker image for this at all, and to build an
image requires us to set some build arguments to useful values. We
also need to provide all artifacts to the build, as the `Dockerfile`
cannot download anything. As a result, the `:distribution:docker`
project now defines a GitHub repository so that Gradle will download
a `tini` binary.

Note that there will need to be corresponding changes to
`release-manager`.
2021-03-26 13:58:03 +00:00
Mark Vieira 00b19d6319
Upgrade bundled JDK to Java 16 (#70502) 2021-03-25 14:52:44 -07:00
Yang Wang 994499d7cc
Service Accounts - New CLI tool for managing file tokens (#70454)
This is the second PR for service accounts. It adds a new CLI tool
elasticsearch-service-tokens to manage file tokens. The file tokens are stored
in the service_tokens file under the config directory. Out of the planned create,
remove and list sub-commands, this PR only implements the create function since
it is the most important one. The other two sub-commands will be handled in
separate PRs.
2021-03-17 20:02:41 +11:00
Rene Groeschke d2114fc79b
Remove flavor field from Distribution packaging tests (#70132) 2021-03-09 15:38:08 +01:00
Akash Gupta 50926fd223
[DOCS] Fixe broken links in README file (#69626)
Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2021-03-01 09:55:27 -05:00
Rory Hunter 080f48a90c
Add `assertBusy` to make a package test more robust (#69324)
Closes #68043.

`PackageTests.test90DoNotCloseStderrWhenQuiet` failed because of a race
between ES startup and the test making an assertion on the ES output.
Fix this by adding a wrapper to retry the assertion for a while, until
either the assertion passes or the timeout expires.
2021-02-23 09:44:52 +00:00
Jason Tedor d3ac7c9806
Remove support for JAVA_HOME (#69149)
This commit removes support for JAVA_HOME. As we previously deprecated
usage of JAVA_HOME to override the path for the JDK, this commit follows
up by removing support for JAVA_HOME. Note that we do not treat
JAVA_HOME being set as a failure, as it is perfectly reasonable for a
user to have JAVA_HOME configured at the system level.
2021-02-17 20:22:44 -05:00
Jason Tedor 0cd4863585
Introduce ES_JAVA_HOME (#68954)
This commit introduces a dedicated envirnoment variable ES_JAVA_HOME to
determine the JDK used to start (if not using the bundled JDK). This
environment variable will replace JAVA_HOME. The reason that we are
making this change is because JAVA_HOME is a common environment variable
and sometimes users have it set in their environment from other JDK
applications that they have installed on their system. In this case,
they would accidentally end up not using the bundled JDK despite their
intentions. By using a dedicated environment variable specific to
Elasticsearch, we avoid this potential for conflict. With this commit,
we introduce the new environment variable, and deprecate the use of
JAVA_HOME. We will remove support for JAVA_HOME in a future commit.
2021-02-17 12:41:23 -05:00
Rory Hunter f35f6360ba
Make docker tests more reliable (#68512)
Closes #66656.

Current, `Docker#verifyOssInstallation(...)` checks the permissions of
`elasticsearch.keystore`, however this often causes problems when a test
forgets to wait for ES and the keystore doesn't exist yet.

Instead, add a test specifically to check `elasticsearch.keystore` and
remove the check from `verifyOssInstallation()`.
2021-02-05 20:48:41 +00:00
Rory Hunter c4da19a60c
Make QuotaAwareFsTests more robust (#68515)
Closes #68436. Attempt to make the quota packaging tests more robust by
only trying to shut down ES if it managed to start up in the first
place.
2021-02-05 13:09:24 +00: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 1665adc7b8
Tweak elasticsearch-env script to work under posix (#68297)
Closes #65980. Also closes #67097 and closes #66656.

The elasticsearch-env script used a bash feature called "process
substitution", which doesn't work when `POSIXLY_CORRECT` is set in the
environment (the construct doesn't even parse). Tweak the implementation
to use something that works under `POSIXLY_CORRECT`.

Also add a test to `ArchiveTests`, which fails without this fix, and
rework `DockerTests.test085EnvironmentVariablesAreRespectedUnderDockerExec`
since a couple of issues were open against it.
2021-02-02 09:47:07 +00:00
Andras Palinkas 4b36ab9ca2
SQL: Fix elasticsearch-sql-cli under docker (#67737)
Calling `./bin/elasticsearch-sql-cli http://localhost:9200`under
docker failed with `ERROR: E is not a recognized option` error
message.

The root cause is that under docker the environmental variables are
automatically appended to the arguments of the sql cli. `"$@"` will
contain `-Evar=value` strings added by the `elasticsearch-env`
(line 122). This change uses the original argument list (saves it
before it is modified) when the sql cli is called.

Fixes #57744
2021-01-25 10:58:17 -05:00
Rory Hunter ea395d3e17
Update ironbank build with latest docker context (#67504)
The file `download.json` is replaced by `hardening_manifest.yaml`, which
includes various pieces of information about the Iron Bank build.
2021-01-18 16:14:45 +00:00
Tanguy Leroux 520c44706e
Mute DockerTests.test085EnvironmentVariablesAreRespectedUnderDockerExec (#67098)
Relates #67097
2021-01-06 14:55:03 +01: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
Rory Hunter 4ff612550e
Allow bootstrap plugins to appear in _cat/plugins (#66260)
Closes #66107.

Bootstrap plugins are not loaded in the main Elasticsearch process, but
instead take effect only when ES is starting. As such, these plugins are
skipped when ES loads all installed plugins.

As a result, it was impossible for the plugins _cat API to report
whether any bootstrap plugins are installed.

Fix this by adjusting how the loading process skips bootstrap plugins,
and then tweaking the plugins _cat API so that bootstrap plugins can
optionally be included in the response.
2020-12-17 09:30:16 +00:00
Mark Vieira a393db9a9a
Autodetermine heap settings based on node roles and total system memory (#65905)
This commit expands our JVM egonomics to also automatically determine
appropriate heap size based on the total available system memory as well
as the roles assigned to the node. Role determination is done via a
naive parsing of elasticsearch.yml. No settings validation is done and
only the 'node.roles' setting is taken into consideration.

For heap purposes a node falls into one of four (4) categories:

1. A 'master-only' node. This is a node with only the 'master' role.
2. A 'ml-only' node. Similarly, a node with only the 'ml' role.
3. A 'data' node. This is basically the 'other' case. A node with any
set of roles other than only master or only ml is considered a 'data'
node, to include things like coordinating-only or "tie-breaker" nodes.
4. Unknown. This is the case if legacy settings are used. In this
scenario we fallback to the old default heap options of 1GB.

In all cases we short-circuit if a user provides explicit heap options
so we only ever auto-determine heap if no existing heap options exist.
Starting with this commit the default heap settings (1GB) are now
removed from the default jvm.options which means we'll start auto-
setting heap as the new default.
2020-12-15 23:10:49 -08:00
Rory Hunter 68b5465575
Make it possible to use Stack logging in Docker (#65778)
Closes #62758.

Include the Stack log4j config in the Docker image, in order to
make it possible to write logs in a container environment in the
same way as for an archive or package deployment. This is useful
in situations where the user is bind-mounting the logs directory
and has their own arrangements for log shipping.

To use stack logging, set the environment variable `ES_LOG_STYLE`
to `file`. It can also be set to `console`, which is the same as
not specifying it at all.

The Docker logging config is now auto-generated at image build time,
by running the default config through a transformer program when
preparing the distribution in an image builder step.

Also, in the docker distribution `build.gradle`, I changed a helper
closure into a class with a static method in order to fix an
issue where the Docker image was always being rebuilt, even when
there were no changes.
2020-12-10 12:25:47 +00:00
Rory Hunter fd675fd836
Introduce licensed plugins (#64850)
This PR introduces the concept of "licensed" plugins. Such plugins
may only be installed on installations of the default distribution,
and this is enforced by the plugin installer. This PR also moves
the `quote-aware-fs` plugin to the `x-pack` directory, and marks
it as licensed.

Note that I didn't move the plugin source under `x-pack/plugin`
because all the existing x-pack plugins are actually bundles as
modules into the default distribution, whereas the `quota-aware-fs`
plugin needs to remain a standalone plugin.
2020-11-17 16:21:57 +00:00
Rene Groeschke 810e7ff6b0
Move tasks in build scripts to task avoidance api (#64046)
- Some trivial cleanup on build scripts
- Change task referencing in build scripts to use task avoidance api
where replacement is trivial.
2020-11-12 12:04:15 +01:00
Rory Hunter c736c94085
Run elasticsearch-node as the right user in package tests (#64858)
Closes #64735.

When running the `elasticsearch-node` tool in the archive packaging
tests with a non-standard data directory, make sure we run the tool as
the same user as Elasticsearch. Some systems place extra restrictions on
`/tmp` that prevent a different user getting a lock on `/tmp/node.lock`.
2020-11-10 15:37:34 +00:00
William Brafford b00cb9efa0
Windows service installation should allow multiple values in ES_JAVA_OPTS (#64254)
* Add tests for using ES_JAVA_OPTS with windows service

* Relocate ES_JAVA_OPTS delimiter munging

* Don't use equals for -Xmx and -Xms args

* Write newlines in temporary configs
2020-10-30 14:13:17 -04:00
Rory Hunter a32a0986c3
Make ES files inside Docker container world readable (#64274)
Running the Elasticsearch Docker image with a different GID is
possible but trappy, since at present all the ES files are only
readable by the user and group. This PR documents a Docker CLI flag
that fixes this situation, by ensuring the container user is added
to the default group (which is `root`, GID 0).

I also added a test for this case, and refactored the Docker tests
to use a builder pattern for constructing the `docker run` command.
The existing code was becoming unwieldy and hard to change.
2020-10-30 13:26:44 +00:00
Rory Hunter 2bf2d649f1
Introduce quota-aware filesystem ES plugin (#63620)
Closes #61145.

This PR adds a quota-aware filesystem plugin to Elasticsearch. This plugin
offers a way to provide user quota limits (specifically, total quota size
and available quota size) to Elasticsearch, in an implementation-agnostic
manner.

As part of this work, this PR also introduces the concept of "bootstrap
only" plugins, which are excluded from the normal plugin loading process.

Finally, note that this implementation supports `createLink(...)`, since ES
/ Lucene use hard links where possible.
2020-10-28 19:57:54 +00:00
Przemysław Hejman c4e75281e2
Fix plugin installation in Docker container as non-default user (#63807) 2020-10-16 17:08:28 +02:00
William Brafford fc6f1456ed
Copy attributes when backing up and restoring custom configurations (#63619) 2020-10-14 09:07:19 -04:00
Rory Hunter ec350157ea
Use a tiny base image for Docker builds (#52519)
Closes #51670, closes #50838.

Introduce a tiny base image for Docker builds. It aims to create a basic filesystem with as little as possible, which is mostly glibc, busybox and bash. A statically-built curl is also provided.

We still use CentOS 8 as a base. All the fun stuff happens in the Dockerfile.
2020-10-12 14:58:01 +01:00
Ryan Ernst 8ba4004dc0
Handle JAVA_HOME better in packaging tests (#62905)
JAVA_HOME is set as necessary in packaging tests, depending on whether
it is needed for no-jdk distributions or testing override behavior. We
currently rely on gradle finding java through PATH. However, JAVA_HOME
can sometimes be set by the system itself, which then leaks through to
the packaging test. This commit reworks our handling of JAVA_HOME to
pass it through for gradle, and then explicitly clear it whenever
running shell commands in packaging tests.
2020-09-24 16:59:25 -07:00
Ryan Ernst 4e4d97eb78
Re-enable PluginCliTests.test20SymlinkPluginsDir (#62736)
This test was disabled with an awaits fix, but the underlying issue has
been worked around, so the test can be re-enabled.

relates #46050
relates #58628
2020-09-24 16:46:23 -07:00
Rory Hunter bd8701da4f
Change approach to checking GID in Docker (#62751)
Closes #62466. Since we're still seeing occasional failures when
checking the GID of all files in the Docker image due to Elasticsearch
running in the background, instead run a new container with ES running
at all.
2020-09-24 09:35:13 +01:00
Rory Hunter 1896fb3cca
Fix log4j config for :qa:os tests (#62234)
The log4j config in :qa:os was broken because it referenced an appender plugin that is not
on that project's classpath. Resolve this by adding a dedicated logging config and removing
the copy step.
2020-09-15 09:16:47 +01:00
Rory Hunter 49f886d1b8
Make Docker test robust when removing a temp dir (#61639)
Closes #61614. Closes #61553.

In a particular Docker test, ensure is shut down before removing the
data directory. Also add the force flag to `rm`.
2020-09-01 12:03:06 +01:00
Rory Hunter 95b8218d51
Allow running the Docker image with a non-default group (#61194)
Closes #60864. Tweak the JDK directories' permissions in the ES
Docker image so that ES can run under a different user and group.

These changes assume that the image is being run with bind-mounted
config, data and logs directories, and reads and writes to these
locations will still fail when both the UID and GID are not the
default. Everything should be OK when running with the default GID
of zero, however.
2020-08-24 11:04:38 +01:00
Rory Hunter 990381fb1e
Fix tests that weren't expecting UBI Docker images (#61362)
Closes #61360.
2020-08-20 13:30:43 +01:00
Rory Hunter 1fe42c9604 Fixes after adding UBI Docker support
The CertGenCliTests needed an update to ignore the UBI Docker
distribution as well as the regular Docker distribution.
2020-08-18 21:05:24 +01:00
Rory Hunter 2e3ed6171e
Add UBI docker builds (#60742)
This PR resurrects support for building Docker images based on one of Red Hat's UBI images. It also adds support for
running the existing Docker tests against the image. The image is named `elasticsearch-ubi8:<version>`.

I also changed the Docker build file uses enums instead strings in a lot of places, for added rigour.
2020-08-18 09:27:23 +01:00
Rory Hunter bf80aa1f69
Wait for ES in Docker to start before checking files (#60825)
Closes #54817.
2020-08-07 14:19:34 +01:00
Ryan Ernst 3052f13333
Remove reference to bats test (#60696)
The packagingTest tasks run by CI (but not by PRs...) was still
refering to bats tasks. This commit removes those remaining references.

closes #60690
2020-08-05 14:58:31 -07:00