Commit Graph

135 Commits

Author SHA1 Message Date
Rory Hunter 51b0c0cb01
Don't export docker images on assemble (#76817)
Our packaging tests set up dependencies so that the tests depend on the
artifact that is going to be tested. For Docker, the tests depend on an
export of the Docker image, partly to follow the pattern, but partly to
support loading the image when the tests are executed inside Vagrant.

There is a sub-project for each type of image that can be exported. The
main Docker build file adds an export task and an artifact to the
sub-project. However, it also makes the export task a dependency of the
sub-project's `assemble` task. This last step isn't necessary for the
tests to run, and causes extra and needless work to be done when running
`assemble` on the entire build. Therefore, removing the last bit of task
wiring.
2021-08-23 20:11:17 +01:00
Rory Hunter f738ba8139 Tweak Dockerfile.cloud-ess
Some Docker builds are apparently complaining about the `COPY` syntax in
this file, so try and fix it as Docker suggests.
2021-08-23 11:19:00 +01:00
Rory Hunter d57b16403b Don't build Cloud docker images on assemble 2021-08-20 21:31:12 +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
Rory Hunter 574211654d
Fixes for Iron Bank (#76087) (#76149)
Second attempt after reverting #76087.

This PR fixes a number of issues with the Iron Bank Docker context. Most
notably it changes the generated `Dockerfile` in the build context to
`COPY` the Elasticsearch archive, instead of downloading it, since Iron
Bank images have a different process and will never be built on Docker Hub.
This requires that the context task be wired to `assemble` instead of the
build image task. The latter is only used for testing purposes.
2021-08-09 14:27:17 +01:00
Rory Hunter 99adde5f5b Revert "Fixes for Iron Bank (#76087)"
This reverts commit 5298c52e8e.
2021-08-05 07:50:27 +01:00
Rory Hunter 5298c52e8e
Fixes for Iron Bank (#76087)
* Fixes for Iron Bank

* Add placeholder for ES tgz checksum
2021-08-04 10:07:07 -04: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 bff790011c Increment Iron Bank base image to 8.4
Acting on a request from the Iron Bank folks.
2021-07-15 21:21:33 +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 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
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
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
Rory Hunter 167ed57a6d
Transform docker log4j properties at build time (#71346)
For the Docker distribution, we transform the archive distribution's
log4j2 config so that all messages are logged to the console by default.
However this transformation step happens when the Docker image is built,
which means that the source for the transformation must be included in
the Docker context.

Improve this by making the archive distribution's log4j config available
as an artifact in the build, then simply copying it into the Docker context.
The transform logic has been reimplemented as a simple copy filter.
Consequently, the `transform-log4j-config` project has been removed.
2021-04-08 09:53:10 +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
Rene Groeschke a329677d4a
Remove oss handling in docker distribution project (#70134)
- Remove docker oss log4j properties
- Remove oss images from docker compose

Follow up on #69775
Related to #68797
2021-03-17 11:20:04 +01:00
Rory Hunter 477ded9769
Include log4j transform jar in docker build context tasks (#69808)
Ensure that the log4j transform jar is included in the generated Docker build context.
Also makes some small fixes to the Iron Bank Dockerfile.
2021-03-03 20:24:43 +00:00
Mark Vieira 3edc532b0e Update ironbank docker build script for changes to dockerBuildContext 2021-03-03 11:07:05 -08:00
Rene Groeschke 74938516ab
Fix dockerBuildContext usage in build scripts (#69896) 2021-03-03 10:55:38 -08:00
Rene Groeschke 24adbbca41
Remove OSS specific distribution packaging (#69775)
* Remove OSS projects from distribution packaging
* Remove OSS flavor from ElasticsearchDistribution
* Remove OSS handling from docker build setup
2021-03-03 13:39:29 +01:00
Jake Landis 3dc9dc01c7
avoid costly regex expression (#69768)
This commit changes part of a regular expression for some tests to
be more performant. While it is difficult articulate why this is change is much
faster, testing has shown for some inputs this match to be less then 1s,
where prior could take over 30s.

related: #69757
2021-03-02 07:35:27 -06:00
Rene Groeschke 487f37fe8f
Remove jcenter repository from our build (#69517)
- JCenter has been deprecated in Gradle
- JCenter was announced to be sunset by JFrog
- Use Gradle plugin portal as maven repository for build dependencies
- Use mavenCentral as general replacement for jcenter

Fixes #68476
2021-02-25 08:36:08 +01:00
Mark Vieira 755615781a
Ensure docker images for current architecture are built for testing (#69554) 2021-02-24 16:09:31 -08:00
Lee Hinman 3f9f007545
Add the frozen tier node role and ILM phase (#68605)
This commit adds the `data_frozen` node role as part of the formalization of data tiers. It also
adds the `"frozen"` phase to ILM, currently allowing the same actions as the existing cold phase.

The frozen phase is intended to be used for data even less frequently searched than the cold phase,
and will eventually be loosely tied to data using partial searchable snapshots (as oppposed to full
searchable snapshots in the cold phase).

Relates to #60848
2021-02-05 14:38:13 -07: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 c841b2c073
Align JSON logs better with ECS (#67266)
The JSON logs that Elasticsearch produces are roughly in an ECS shape. This PR improves
that alignment.
2021-01-25 10:43:37 +00:00
Rory Hunter 677cbdd650 Fix typo in DSOP hardening_manifest.yml 2021-01-19 16:06:46 +00: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
Rory Hunter 7fba77c950
Tweaks to the Iron Bank docker context (#66942)
This PR makes a few tweaks to the Docker context that the ES build can generate,
in order to align it more closely with what we submit to DSOP.
2021-01-05 16:46:40 +00: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 7ed43a9e1e Forward-port improvements to transform-log4j-config from 7.x 2020-12-10 19:35:00 +00: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 533f77b430
Rework Dockerfile instructions to save space (#65308)
In PR #64274, we make it possible to run our Docker images more easily
under a different group, but in so doing increased the Docker layer
sizes dramatically, effectively doubling the size of the images.

Fix this by reworking what commands get run and where, in order to bring
down the final size of the images.
2020-11-20 15:35:47 +00:00
Rory Hunter 30abc09a68
Add retries to Docker build apk commands (#65194)
Most of the Elasticsearch Docker build process implements retries
in order to make the process more robust in the face of transient
errors e.g. network failures. However, we missed out the `apk`
command in `master`'s Dockerfile. This PR adds the same retry loop
around `apk` as features elsewhere in the `Dockerfile`.

As part of this, I implemented a helper closure that generates the
same loop construct throughout the `Dockerfile`.
2020-11-20 08:03:07 +00:00
Rory Hunter 1ad9790d9d Fix typo in generated Dockerfile for UBI 2020-11-17 18:56:45 +00:00
Rory Hunter f1cf7c1402 Don't define tasks for building IronBank Docker images 2020-11-17 15:12:12 +00:00
Rory Hunter e07adb75c9
Support building Iron Bank Docker context (#64336)
This PR adds support for building a Docker context for Iron Bank.
It doesn't actually build the image - we could add that at a later
stage, but this is an attempt to automate at least some of the
process.

Iron Bank is a lot like our UBI build, except it uses a hardened
version of the full UBI image, not the minimal UBI image. They have
particular requirements around how the Docker context should be
arranged. The Docker build cannot fetch its own artefacts, but
instead the context provides a descriptor that locates what is
needed for the build.

I also added a filter so that after performing expansions on the
`Dockerfile`, we squash long runs on newlines together. This makes
the output cleaner, while allowing us to break up the unprocessed
`Dockerfile` for clarity.
2020-11-16 12:21:35 +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
Ryan Ernst 2fffd78125
Use no-kpi subdomains for tests downloading artifacts (#64502)
This commit converts build code that downloads distributions or other
artifacts to use the new no-kpi subdomain, and removes the formerly used
no-kpi header.
2020-11-07 11:27:58 -08: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
Jason Tedor 117d79b5e9
Adjust defaults for tiered data roles (#64015)
This commit adjusts the defaults for the tiered data roles so that they
are enabled by default, or if the node has the legacy data role. This
ensures that the default experience is that the tiered data roles are
enabled.

To fully specifiy the behavior for the tiered data roles then:
 - starting a new node with the defaults: enabled
 - starting a new node with node.roles configured: enabled if and only
   if the tiered data roles are explicitly configured, independently
   of the node having the data role
 - starting a new node with node.data enabled: enabled unless the
   tiered data roles are explicitly disabled
 - starting a new node with node.data disabled: disabled unless the
   tiered data roles are explicitly enabled
2020-10-27 12:47:14 -04:00
Rory Hunter 9a8be26cc8
Explicitly retry failed docker pulls (#63946)
Closes #63869. Perform `docker pull` explicitly instead of as part of
`docker build`, and wrap it in a retry loop. This is an attempt to make
the build more resilient to transient errors.
2020-10-21 13:31:32 +01:00
Przemysław Hejman c4e75281e2
Fix plugin installation in Docker container as non-default user (#63807) 2020-10-16 17:08:28 +02:00