Commit Graph

184 Commits

Author SHA1 Message Date
Rene Groeschke 69d87e1bfd
Rework beats artifacts resolution in docker build (#100157)
* Rework metricbeat artifacts resolution to avoid misleading error message
* Pass File object to beats repo uri to workaround parsing problems
2023-10-06 17:04:46 +02:00
Rene Groeschke cc2a711b2d
Always use es tarball for creating IronBank docker context (#95958)
This fixes an issue with building iron bank images that are handled differently
than other docker images.
2023-05-09 17:39:35 +02:00
Rene Groeschke 778adc8622
Make es docker image creation more efficient (#95883)
We want avoid packing and unpacking elasticsearch archives to safe build time
2023-05-08 18:20:10 +02:00
Michael Montgomery a0056941e5
Use UID for dockerfile to allow runAsNonRoot to be used. (#95390)
Signed-off-by: Michael Montgomery <mmontg1@gmail.com>
2023-04-19 12:26:26 -07:00
Rene Groeschke e735455431
Provide hints to Gradle Task.onlyIf declarations (#94953)
* Update gradle enterprise plugin to show skip reasons in build scans
* Unify OS specific handling in build logic
2023-03-31 23:57:55 +02:00
Mark Vieira 315fa321ae
Improve efficiency of packer cache script (#94701) 2023-03-23 13:29:45 -07:00
Mark Vieira 30faac838a
Ensure correct architecture for beats is used in cloud docker images (#92997) 2023-01-17 10:56:45 -08:00
Mark Vieira c2eda511de
Add JUnit rule based integration test cluster orchestration framework (#92379)
This commit adds a new test framework for configuring and orchestrating
test clusters for both Java and YAML REST testing. This will eventually
replace the existing "test-clusters" Gradle plugin and the build-time
cluster orchestration.
2022-12-21 15:33:46 -08:00
Dimitrios Liappis a6351aae3b
Add docs about multi-arch Docker builds (#92185)
Enhance docker distribution project docs with prerequisites for building
multi-architecture images.
2022-12-07 13:08:53 +02:00
Mark Vieira e68e28e4cb Ensure beats are bundled in Cloud docker image during DRA builds
(cherry picked from commit 210d4576fa)
2022-11-16 16:15:23 -08:00
Rene Groeschke f6b1087f30
Provide compressed docker image exports for DRA process (#91593)
Initial fix for providing the expected Docker files for our DRA process
- Can be tweaked to be more efficient, but kept simple for now
2022-11-15 11:39:56 -05:00
Mark Vieira 143828e4f4
Add `exportDockerImages` lifecycle task for exporting docker tarballs (#91571)
We need exported Docker artifacts for the release process. Add a
lifecycle task to generate these artifacts.
2022-11-14 20:00:16 -05:00
Rene Groeschke f880d41669
Add DRA snapshot build (#91018)
* Add support for building against defined build-ids of dependent artifacts
* Introduce DraResolvePlugin and functional tests
* Declare initial dra snapshot ci job for elasticsearch

We run the DRA builds against ubuntu as other release related ci jobs have in the past. Also we only have libs2xmlutills available on our ubuntu based ci workers
2022-11-09 16:16:21 +01:00
Mark Vieira 3c3a70cbeb Add extensions points for building customized Docker images 2022-09-30 15:43:31 -07:00
Mark Vieira 3603aa7151
Use architecture specific tag for building cloud-ess image (#90074) 2022-09-15 16:19:30 -07:00
Mark Vieira fa38d1ba8f
Allow for building multi-arch docker images via buildx (#89986) 2022-09-13 08:32:55 -07:00
Mark Vieira 5ebaece2ba
Use DRA artifacts for beats and ML dependencies (#89951) 2022-09-09 13:05:19 -07:00
Rory Hunter ec8af834f4
Write docs about our Docker build setup (#89036)
Add a README.md to the docker distribution project, with details
about how we build and test our images.
2022-08-03 11:02:27 +01:00
Mark Vieira 41af3cb8e5
Ignore beats artifacts when resolving all artifact dependencies (#88960) 2022-07-29 13:32:24 -07:00
Rory Hunter d5b1356b6c
Fix docker positional params (take 2) (#88584)
As part of #50277, we removed the `TAKE_FILE_OWNERSHIP` option from the
Docker entrypoint script and the associated chroot calls, and instead
just defaulted to running the image as `elasticsearch` instead of
`root`.

However, we didn't check that it was still possible to pass CLI options
to Elasticsearch via CLI arguments, and broke this by mistake. This is
probably an uncommon pattern, versus environment variables or a config
file.  Nevertheless, it is supposed to be possible and is mentioned in
the documentation.

Fix the problem by suppling the missing positional params when calling
Elasticsearch, and add a test case so that we don't break it again.
2022-07-19 09:17:36 +01:00
Rory Hunter ffc6a14755 Revert "Fix passing positional args to ES in Docker (#88502)"
This reverts commit 9f4b32a20a.
2022-07-18 09:28:49 +01:00
Rory Hunter 9f4b32a20a
Fix passing positional args to ES in Docker (#88502)
As part of #50277, we removed the `TAKE_FILE_OWNERSHIP` option from the
Docker entrypoint script and the associated chroot calls, and instead
just defaulted to running the image as `elasticsearch` instead of
`root`.

However, we didn't check that it was still possible to pass CLI options
to Elasticsearch via CLI arguments, and broke this by mistake. This is
probably an uncommon pattern, versus environment variables or a config
file.  Nevertheless, it is supposed to be possible and is mentioned in
the documentation.

Fix the problem by suppling the missing positional params when calling
Elasticsearch, and add a test case so that we don't break it again.
2022-07-14 09:12:04 +01:00
Rene Groeschke dbf39741a0
Make LoggedExec gradle task configuration cache compatible (#87621)
This changes the LoggedExec task to be configuration cache compatible. We changed the implementation
to use `ExecOperations` instead of extending `Exec` task. As double checked with the Gradle team this task
is not planned to be made configuration cache compatible out of the box anytime soon.

This is part of the effort on https://github.com/elastic/elasticsearch/issues/57918
2022-07-11 08:46:54 +02:00
Rory Hunter cb70dac016
Remove vim-tiny from Docker build (#87812)
Closes #85634.
2022-06-21 10:22:18 +01:00
Rene Groeschke bf4304d18a
Remove elasticsearch.rest-test gradle plugin (#85491)
Removes and remaining usages of `elasticsearch.rest-test` and the plugin itself from the codebase

Relates to https://github.com/elastic/elasticsearch/issues/63696
2022-05-17 11:23:04 +02:00
Rory Hunter 31be78b13d
Update Iron Bank base image to 8.6 (#86796)
Iron Bank have advised us to upgrade the UBI base image.
2022-05-16 21:35:17 +01:00
Przemyslaw Gomulka 4958642404
Disable deprecation log indexing in docker test (#85150)
Deprecation log indexing can make test very fragile
and randomly failing during cluster cleanup.
This commit disables indexing of deprecation logs for :distribution:docker tests

closes #79803
2022-03-21 12:05:49 +01:00
Rory Hunter 728ef33844
Remove use of Cloudflare zlib (#84680)
Relates to #81662. This library isn't ready for public consumption.
Remove it from the Docker build.
2022-03-07 10:03:39 +00:00
Rene Groeschke a86f9c5f02
Remove usage of deprecated Provider#forUseAtConfigurationTime (#83932)
Remove gradle api usage that has been deprecated with Gradle 7.4
2022-02-15 08:06:22 -05:00
Rory Hunter a5afbcd05f
Allow aarch64 ironbank image, fix enrollment test (#82563)
Fixes #81999.

Change `EnrollmentProcessTests` and the testing infrastructure so
that `ServerUtils` can send requests to the correct local port.
This is also a step towards addressing #79688.

Also change the Iron Bank build to that it works on aarch64. This
isn't currently a supported configuration, but it's useful for
testing.
2022-01-13 21:21:59 +00:00
Rory Hunter d2dbef5063
Convert repository plugins to modules (#81870)
Closes #81652.

Convert the `repository-azure`, `repository-gcs` and `repository-s3`
plugins into modules, so that they are always included in the
Elasticsearch distribution. Also change plugin installation, removal
and syncing so that attempting to add or remove these plugins still
succeeds but is now a no-op.
2022-01-10 10:45:42 +00:00
Rory Hunter f63ac249d7 Fix Cloud docker image entrypoint generation
For some reason, the way we generate `/app/elasticsearch.sh` for Cloud
images has broken. It may be the result of changing the default shell to
`bash`. Fix by adding `-e` to the `echo` command.
2021-12-17 13:27:32 +00:00
Rory Hunter 4544196c74
Change default shell to bash in default Docker image (#81828)
As a result of changing the base Docker to Ubuntu in #80820, the default shell
i.e. `/bin/sh` changed to `dash`, rather than `bash`, which could impact anyone
invoking `/bin/sh` and expecting it to still propagate environment variables with
periods in their names.

Reconfigure the default shell back to `bash` so that this type of situation works
again.
2021-12-17 09:38:36 +00:00
Rory Hunter 91b4f6ebdc
Improve Docker image's cacert scripting (#81659)
Apply suggestions from Docker Inc about how to update the `cacerts` in
our Ubuntu-based Docker image. Instead of copying around files and
symlinking, instead install `ca-certificates` and `p11-kit`, and use the
latter to regenerate Java's `cacerts`, as well as ensuring it is
regenerated if the system ca certs are updated.
2021-12-13 15:42:59 -05:00
Rory Hunter d154989cae Upgrade IronBank base image from 8.4 to 8.5 2021-12-13 19:51:53 +00:00
Ioannis Kakavas 54eb955a65
Docker fix additional nodes (#81082)
Allow users to pass an ENROLLMENT_TOKEN environment variable that
would be passed as the `--enrollment-token` parameter to the
elasticsearch executable running in the container. This allows an
elasticsearch node running in docker to enroll itself to an
existing secured cluster.

Resolves: #81068
2021-12-07 18:10:05 +02:00
Rory Hunter 1f5a0ed2d1
Use Cloudflare's zlib in Docker images (#81245)
Closes #81208. Elasticsearch uses zlib for two purposes:    *
Compression of stored fields with `index.codec: best_compression`,     
which we use for observability and security data.    * Request /
response compression. Historically, zlib was packaged within the JDK, so
that users wouldn't have to have zlib installed for basic usage of Java.
However, the original zlib optimizes for portability and misses a number
of important optimizations such as leveraging vectorization support for
x86 and ARM architectures. Several forks have been created in order to
address this. Since version 9, the JDK uses the system's zlib when
available and falls back to the zlib that is packaged within the JDK if
a system zlib cannot be found. This commit changes the Docker image to
install the Cloudflare fork of zlib, and run Java using the fork instead
of the original zlib, so that users of the Docker image can get better
performance. Other ES distribution types are out-of-scope, since
configuring the JVM to use an alternative zlib requires an environment
config as well as installed another zlib, and Docker is the only
distribution type where we can control both.
2021-12-03 04:48:45 -05:00
Rory Hunter 06304615d4
Check downloaded beats archives (#81222)
Part of #81150. Sometimes, building the Cloud Docker images fails due to
some issue with the `.tar.gz` files. Add extra checks and error messages
so that we have a better idea what the precise problem is.
2021-12-01 20:27:39 +00:00
Rory Hunter 4cb6fb925e
Install wget in Cloud Docker images (#80870)
Cloud needs wget to be available in 8.x, so add it to their Docker images.
2021-11-19 19:51:38 +00:00
Rory Hunter 7ec32669f6
Switch to Ubuntu docker base image (#80640)
Switch the ES base Docker image for the default and Cloud images to `ubuntu:20.04`,
as Ubuntu has a more favourable posture on security updates.
2021-11-18 10:10:36 +00:00
Rory Hunter 3018e52335
Introduce declarative plugin management (#77544)
Closes #70219.

Introduce a declarative way for the Elasticsearch server to manage plugins,
which reads the `elasticsearch-plugins.yml` file and works which out
plugins need to be added and / or removed to match the configuration. Also
make it possible to configure a proxy in the config file, instead of
through the environment.

Most of the work of adding and removing is still done in the
`InstallPluginAction` and `RemovePluginAction` classes, so the
behaviour should be the same as with the `install` and `remove`
commands. However, these commands will now abort if the above config
file exists. The intent is to make it harder for the configuration
to drift.

This new method only applies to `docker` distribution types at the
moment.

Since this syncing mechanism declarative, rather than imperative,
the Cloud-specific plugin wrapper script is no longer required.
Instead, an environment variable informs `InstallPluginAction` to
install plugins from an archive directory instead of downloading
them, where possible.
2021-11-15 14:41:11 +00:00
Rory Hunter 46dc92dbff Additional fixes to Cloud docker image after ba87234f51 2021-11-10 13:41:43 +00:00
Rory Hunter ba87234f51
Use almalinux as the Docker base image (#80524)
Closes #76681. Our approach to using `scratch` for building Docker
images has caused problems at Docker Hub. Fix this situation by
removing the whole process of using scratch and instead bases the
default distribution on `almalinux:8.4-minimal`. Alma Linux is
binary-compatible with RHEL, and therefore very similar to UBI.
2021-11-10 13:04:56 +00:00
Mark Vieira 12ad399c48 Reformat Elasticsearch source 2021-10-27 08:19:51 -07:00
Rory Hunter a1aead836e Tweaks for Iron Bank 2021-10-14 20:02:56 +01:00
Rory Hunter 67e310e989
Improve Docker image caching and testing (#78552)
Firstly: we tag our Docker images with various pieces of information,
including a timestamp for when the image was built. However, this makes
it impossible completely cache the image. When developing the Docker
images, it's very tedious to completely rebuild an image for every
single change. Therefore, provided we're not building a proper release
build, we fix the build time to midnight so that the Docker build cache
is usable.

Secondly: the `DockerBuildTask` outputs a marker file to indicate that
an image has been built, but that isn't enough for a meaningful
up-to-date check by Gradle. Improve this by fetching the newly-built
image's hash, and writing that to the output file.

Thirdly: improve the Docker tests to make them more ergonomic, and also
disable `ingest.geoip.downloader.enabled` by default.

Fourthly: add missing test coverage for sourcing settings from env vars.
2021-10-07 09:19:53 +01:00
Mark Vieira dfdbb758e1
Ensure docker test fixture preProcess task is always executed (#78421) 2021-09-29 08:07:50 -07:00
Rory Hunter 96cc5118d1
Fix shell retry generator for shells other than bash (#77422)
Closes #77414.

The generated shell logic in ShellRetry doesn't work in more basic shells, so instead
of using the {1..10} construct, expand the sequence.
2021-09-10 14:10:22 +01:00
Rory Hunter 8ca2c2dbc0
Only depend on beats when necessary (#77436)
* Only depend on beats when necessary

The unified build happens in stages, and for release builds the main
part of Elasticsearch will be built before the Beats distributions are
available. To work around this, infer in the Docker part of the build
whether to include beats as a dependency.  In the future, we should find
a more robust mechanism.

* Move decision about including beats
2021-09-08 09:59:10 -04:00
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