Commit Graph

153 Commits

Author SHA1 Message Date
Rory Hunter d23837499d
Handle cgroups v2 in `OsProbe` (#77128)
Closes #76812. Closes #77126.

OsProbe was only capable of handle cgroup data in the v1 format.
However, Debian 11 uses cgroups v2 by default, and Elasticsearch isn't
capable of reporting any cgroup information. Therefore, add support for
the v2 layout.

Note that we have to open access to all of /sys/fs/cgroup because with
cgroups v2, the files we need are in an unpredictably location.
2021-09-03 15:49:56 +01:00
Rory Hunter 33c4129a60 Revert "Reapply "Handle cgroups v2 in `OsProbe` (#76883)" (#77106)"
This reverts commit 54d4737b23.
2021-09-01 14:32:24 +01:00
Rory Hunter 54d4737b23
Reapply "Handle cgroups v2 in `OsProbe` (#76883)" (#77106)
Re-apply #76883. Somehow a line was missed from security.policy.
2021-09-01 11:46:49 +01:00
Rory Hunter 54a9c3ba05 Revert "Handle cgroups v2 in `OsProbe` (#76883)"
This reverts commit e827ec6078.
2021-09-01 09:42:45 +01:00
Rory Hunter e827ec6078
Handle cgroups v2 in `OsProbe` (#76883)
Closes #76812.

`OsProbe` was only capable of handle cgroup data in the v1 format.
However, Debian 11 uses cgroups v2 by default, and Elasticsearch isn't
capable of reporting any cgroup information. Therefore, add support for
the v2 layout.
2021-09-01 09:29:01 +01:00
Ioannis Kakavas 3a1f40302b
Remove keystore initial_md5sum (#76835)
Elasticsearch's keystore initial md5sum was added in #28928 with
the intention to allow us to remove the elasticsearch.keystore
file upon package removal, if this hadn't been altered after
installation. At that time this decision made perfect sense as
the elasticsearch keystore only contains transient data by
default ( keystore.seed ) that is meant to be useful for bootstrap
related actions, and doesn't need to survive re-installations.

With Security ON by default, we will be storing additional
settings in the keystore upon installation(namely, the passwords
for the PKCS#12 keystores used for TLS) and these have a more
persistent nature. Since `remove` doesn't delete the configuration
directories and files where said PKCS#12 keystores are stored, it
makes sense to also not delete the elasticsearch.keystore which
stores the passwords.
2021-08-23 22:28:13 +03:00
Rory Hunter a1fb9a92bb Fix DockerTests.test010Install 2021-08-23 16:42:34 +01:00
Rory Hunter b8c356f7e6 Mute DockerTests.test140CgroupOsStatsAreAvailable
See #76812
2021-08-23 13:34:22 +01:00
Rory Hunter a6f2a4df8b
Introduce Cloud docker variant (#74980)
Closes #74795.

Introduce two Docker image variants for Cloud. The first bundles
(actually installs) the S3, Azure and GCS repository plugins. The
second bundles all official plugins, but only installs the repository
plugins.

Both images also bundle Filebeat and Metricbeat.

The testing utils have been refactored to introduce a `docker`
sub-package. This allows the static `Docker.containerId` to be
shared without needing all the code in one big class. The code for
checking file ownership / permissions has also been refactored to
a more Hamcrest style, using a custom Docker file matcher.
2021-08-20 20:11:05 +01:00
Ryan Ernst 96627dfa14
Remove quota-aware-fs plugin (#76352)
The quota aware filesystem was added as a means of allowing
Elasticsearch to track the used space of the underlying filesystem in
virtualized environments. However, the need for it was due to a bug in a
much earlier version of Elasticsearch that always found the underlying
mount and checked it directely for usage. That bug has already been
fixed, so the there is no longer a need for this plugin. This commit
removes the plugin. We should consider separately whether there is still
a need for bootstrap plugins.

closes #70309
2021-08-11 15:12:50 -07:00
Lukas Wegmann ad6e0dc6cb
Mute PackageUpgradeTests.test21CheckUpgradedVersion (#76286) 2021-08-10 14:01:47 +02:00
Ioannis Kakavas 81a230dd79
Fix PackageUpgradeTests - v2 (#76259)
Update to https://github.com/elastic/elasticsearch/pull/76235
using the correct password this time.
2021-08-10 07:31:43 +03:00
Ioannis Kakavas 3a361426a1
Fix PackageUpgradeTests test (#76235) 2021-08-09 20:24:49 +03:00
Rory Hunter 3bec319e26
Change env var prefix in Docker settings support (#76192)
Closes #76148. Previously, in #74327, we added support for setting
Elasticsearch settings in the Docker image via environment variables.
However there are scenarios e.g in Kubernetes where it is easy to
accidentally define environment variables that the ES startup process
rejects.

Work around this by using the more explicit env var prefix
`ES_SETTING_`.
2021-08-09 09:47:29 +01:00
Ioannis Kakavas fed790e4e4
Set xpack.security.enabled to true for all licenses (#72300)
This change sets the default value for `xpack.security.enabled` to true
for all licenses. As such the value of the settings is read directly 
from the node's settings and not from XPackLicenseState which 
doesn't need to keep track of it depending on potential license changes
any more.
2021-08-09 09:36:01 +03:00
Rory Hunter 3740f67a14
Tighten up write permissions in Docker image (#70635)
Explicitly set permissions for all files in the Elasticsearch home
directory to the minimum required set, and change ownership to
`root:root` where possible.
2021-08-02 14:25:40 +01:00
Rory Hunter a21ca103b2
Wait for ES to finish startup during password tests (#75420)
Closes #74063.
2021-07-21 09:42:10 +01:00
Albert Zaharovits b9bc7a6f3f
Configure security for the initial node cli (#74868)
This introduces a new cmd line tool that generates the security configuration
for a new node in a new cluster (as opposed to joining an existing cluster).
The security configuration consists of TLS key and certificates, which
are stored in a directory inside the config path, as well as settings appended
to the elasticsearch.yml referencing the aforementioned certs.
2021-07-21 07:45:39 +03:00
Rory Hunter d08b851a5b
Accept settings in snake case in Docker image (#74327)
Closes #74036. Since some orchestration platforms forbid periods in
environment variable names, allow Docker users to pass settings to ES
using an alternative name scheme. For example:

    bootstrap.memory_lock

...becomes:

    ES_BOOTSTRAP_MEMORY__LOCK

The setting name is uppercased, prefixed, all underscores are converted
to double underscores, and all periods are converted to underscores.
2021-07-09 19:46:58 +01:00
Rory Hunter 47029736cf
Pin Alpine Linux version in Docker builds (#74169)
Alpine Linux 3.14.0 is incompatible with older versions of Docker, so pin the
version that we use to 3.13. At some point in the future, it will
be possible to upgrade Alpine.

Also when compiling curl, if the configure step fails and a config.log
file exists, then dump it out before exiting to assist diagnosis.
2021-06-16 14:29:00 +01:00
Rory Hunter a5d2251064
Order imports when reformatting (#74059)
Change the formatter config to sort / order imports, and reformat the
codebase. We already had a config file for Eclipse users, so Spotless now
uses that.

The "Eclipse Code Formatter" plugin ought to be able to use this file as
well for import ordering, but in my experiments the results were poor.
Instead, use IntelliJ's `.editorconfig` support to configure import
ordering.

I've also added a config file for the formatter plugin.

Other changes:
   * I've quietly enabled the `toggleOnOff` option for Spotless. It was
     already possible to disable formatting for sections using the markers
     for docs snippets, so enabling this option just accepts this reality
     and makes it possible via `formatter:off` and `formatter:on` without
     the restrictions around line length. It should still only be used as
     a very last resort and with good reason.
   * I've removed mention of the `paddedCell` option from the contributing
     guide, since I haven't had to use that option for a very long time. I
     moved the docs to the spotless config.
2021-06-16 09:22:22 +01:00
Rory Hunter ee98e8593b
Tighten up write permissions in Docker image (#73942)
Recursively remove write access from the bin, jdk, lib and
modules directories, since this access is not required, and removing
it makes it harder to exploit other issues in an ES distribution.
2021-06-11 13:31:49 +01: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
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