Commit graph

1378 commits

Author SHA1 Message Date
Rene Groeschke
00f2dc09ff
Avoid overhead of zip / unzip modules when packaging distribution (#84660)
This removes the overhead of zipping up modules that are immediately unzipped again when packaging
the elasticsearch distribution.
We also move some logic for packaging the elasticsearch distribution into a plugin and remove some outdated
overhead dealing with 'meta plugins' when copying modules into a distribution.

Another follow up and related optimization out of scope of this PR is, to also not zip unzip modules declared
for usage in our test cluster setups.

This partially addresses #76726.
2022-03-15 11:37:47 +01:00
Mark Vieira
0c6f131fbf
Remove usages of elasticsearch.build plugin in non-production projects (#84890) 2022-03-14 11:27:24 -07:00
Nikola Grcevski
5ae99a6297
Warn on slow signature verification (#84766)
Plugin downloads can sometimes take unexpectedly
long because of slow random number generation on certain
operating system versions, e.g. Debian based OS
distros with kernels older than 5.6. This PR adds
a warning message for users explaining why plugin
installation from remote URLs is taking unexpectedly long.
2022-03-11 16:28:16 -05:00
Ievgen Degtiarenko
01c5bc04e8
replace .collect(toUnmodifiableList()) with .toList() (#84760)
Replace collect with a simipler toList call that also creates immutable
collection.
2022-03-10 10:27:46 +01:00
Ryan Ernst
5f06b5f627
Add x-content testing jar (#84775)
This commit adds a jar separate from the test framework to provide
utilities for testing x-content related code. The first thing moved
there is the base schema validation test case, which also pulls along
the com.networknt dependency and jackson. For now these are direct
dependencies, though we could consider shading them in the future so as
not to expose downstream projects to them, which may have version
conflicts.
2022-03-09 09:48:34 -08:00
Chris Hegarty
50528d5d79
Add missing explicit no-args ctors (#84763) 2022-03-09 11:08:48 +00:00
Ryan Ernst
070fcaa0ad
Move x-content implementation to a separate classloader (#83705)
This change isolates the Jackson implementation of x-content parsers and generators to a separate classloader. The code is loaded dynamically upon accessing any x-content functionality.

The x-content implementation is embedded inside the x-content jar, as a hidden set of resource files. These are loaded through a special classloader created to initialize the XContentProvider through service loader. One caveat to this approach is that IDEs will no longer trigger building the x-content implementation when it changes. However, running any test from the command line, or running a full Build in IntelliJ will trigger the directory to be built.

Co-authored-by: ChrisHegarty <christopher.hegarty@elastic.co>
2022-03-07 15:44:59 -08: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
Mark Vieira
e7b29abf11
Use 'main' when referring to default branch (#84463)
Replace any old references of master with main. These are mostly
cosmetic, as the name of the default branch doesn't actually affect the
build in any meaningful way.
2022-03-01 12:28:45 -08:00
Ryan Ernst
400fb28845
Separate launcher tools classpath (#84475)
The tools used in launching Elasticsearch have a separate jar file and
dependencies. This commit moves the launcher tools to its own lib
directory, so that it does not bleed into the main Elasticsearch
classpath.
2022-03-01 07:19:10 -08:00
Nik Everett
3c66958f08
Remove deprecated xcontent method (#84314) (#84372)
This removes one of the `createParser` methods that I deprecated in 
#79814, migrating callers to one of the new methods that it created.
2022-02-28 16:02:09 -05:00
Rory Hunter
fb5b44c522 Restart ES after keystore upgrade in postinst (#84224)
Closes #82433. If the environment variable `RESTART_ON_UPGRADE` is true,
then ensure that we delay restarting Elasticseach until after the
keystore is upgraded, or else we can run into permissions problems.
2022-02-24 09:28:49 +00:00
Andrii Nikitiuk
4d3d0b434c
Removing io.netty.allocator.numDirectArenas override. (#76593)
This flag has already been removed by ES on Oct 21, 2019 after they created their own allocator: 547e399dbf
However, in parallel, on Oct 28, 2019 all command line flags were moved from jvm.options file into the launcher, and this option has been re-introduced: c4fbda3310

See original commit from Oct 21 for the reasoning on why this flag is not needed anymore.
2022-02-22 17:23:54 -07:00
Mayya Sharipova
26c3dd6857
Upgrade to lucene-9.1.0-snapshot-1336263051c (#83667)
Lucene issues that resulted in elasticsearch changes:

LUCENE-9820 Separate logic for reading the BKD index from logic to intersecting it.
LUCENE-10377: Replace 'sortPos' with 'enableSkipping' in SortField.getComparator()
LUCENE-10301: make the test-framework a proper module by moving all test
classes to org.apache.lucene.tests
LUCENE-10300: rewrite how resources are read in ukrainian morfologik analyzer:
LUCENE-10054 Make HnswGraph hierarchical
2022-02-22 09:53:20 +01: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
Ioannis Kakavas
facec15e87
Upgrade jANSI dependency to 2.4.0 (#83566)
2.4.0 Introduces support for linux and macOS aarch64. Without this
we cannot detect whether a terminal is attached to elasticsearch
on macoOS/linux aarch64 and so we do not generate and print the
elastic password and enrollment token on startup
2022-02-07 11:44:37 +02:00
Albert Zaharovits
035fdd895d
Disable ANSI formatting for security autoconfiguration on Windows cmd line (#83326)
In order to display formatted (bolded) autoconfiguration text on
Windows cmd prompt using JANSI, one needs to invoke the
SetConsoleMode Kernel32 API, via JANSI's AnsiConsole#install.
But we lack the testing infra to properly assert the formatting behavior,
so this PR disables ANSI-formatted output on Windows cmd prompt.

Fixes: #83316
2022-01-31 16:36:02 +02:00
Albert Zaharovits
6687a28e4e
Display security auto-configuration with fancy unicode (#82740)
This PR slightly improves the format of the security auto-configuration
information that is printed on the terminal when the initial cluster
node first starts up.

It uses eye-catching Unicode characters for bullet points.
It also uses Unicode to display a continuous border, for the whole
width of the terminal, before and after the information. In addition,
it uses ANSI escape sequences to render some of the information
in bold fonts.

It will fallback to using regular characters if the JVM is set-up with
a non-UTF encoding for the standard out.
2022-01-25 11:00:37 +02:00
Artem Prigoda
cce5ad2e4f
Migrate to Java16 records (part 2) (#82914)
Try to represent immutable data with Java records introduced in JEP 395

Convert only existing immutable classes, no "POJO with setters to a record" refactorings.
2022-01-25 00:31:15 +01:00
Artem Prigoda
fc5a820da9
Migrate to Java 16 Records (part 1) (#82338)
Try to represent immutable data with Java records introduced in [JEP 395](https://openjdk.java.net/jeps/395)
2022-01-18 17:53:06 +01: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
Artem Prigoda
0699c9351f
Use Java 14 switch expressions (#82178)
JEP 361[https://openjdk.java.net/jeps/361] added support for switch expressions
which can be much more terse and less error-prone than switch statements.

Another useful feature of switch expressions is exhaustiveness: we can make
sure that an enum switch expression covers all the cases at compile time.
2022-01-10 09:53:35 +01:00
Albert Zaharovits
9e9a8cc7d0
Auto-generated TLS files under fixed config path (#81547)
We (mostly I) were initially advocating for the auto-generated files to
use unique names (the name containing a timestamp particle), in order to
avoid that subsequent invocations of the config step conflict with
itself. Moreover, I was wishing that these files will not have to be
handled directly by admins (that the enrollment process was to be used).
However, experience proved us otherwise, admins have to manipulate these
files, and unique configuration names are hard to deal with in scripts
and docs, so this PR is all about using a fixed name for all the
generated files. _Labeling as a bug fix because the feedback is that it
very negatively impacts usabilty._ Closes
https://github.com/elastic/elasticsearch/issues/81057
2021-12-29 12:56:29 -05: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
Artem Prigoda
763d6d510f
Use Java 15 text blocks for JSON and multiline strings (#80751)
The ES code base is quite JSON heavy. It uses a lot of multi-line JSON requests in tests which need to be escaped and concatenated which in turn makes them hard to read. Let's try to leverage Java 15 text blocks for representing them.
2021-12-15 18:01:28 +01: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
Mark Vieira
9a3422e1a6
Patch log4j JAR to remove JndiLookup class (#81629) 2021-12-10 15:51:38 -08:00
Chris Hegarty
ef64808caf
Add logging property (#81622) 2021-12-10 16:42:15 +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
Chris Hegarty
c16dd35b81
Fix split package between libs/cli and server, move org.elasticsearch.cli to org.elasticsearch.common.cli (#81038)
Fix the split package org.elasticsearch.cli, between server and the cli library. Move the server org.elasticsearch.cli package to org.elasticsearch.common.cli. Removing split packages is a prerequisite to modularization.
2021-11-25 14:42:22 +00:00
Chris Hegarty
e6e812c75f
Allow to set the security manager (#80957)
Post JDK 17 the security manager is disabled by default - setSecurityManager throws UOE - see JEP 411.

This change adds a command line option to explicitly allow to set the security manager, which enables early testing with releases greater than JDK 17.
2021-11-24 09:51:13 +00:00
Rory Hunter
7db06c110b
Fix shadowed vars pt6 (#80899)
Part of #19752. Fix more instances where local variable names were shadowing field names.
2021-11-23 09:51:09 +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
David Turner
57dbefe4fb
Set LIBFFI_TMPDIR at startup (#80651)
Today if `libffi` cannot allocate pages of memory which are both
writeable and executable then it will attempt to write code to a
temporary file. Elasticsearch configures itself a suitable temporary
directory for use by JNA but by default `libffi` won't find this
directory and will try various other places. In certain configurations,
none of the other places that `libffi` tries are suitable. With older
versions of JNA this would result in a `SIGSEGV`; since #80617 the JVM
will exit with an exception.

With this commit we use the `LIBFFI_TMPDIR` environment variable to
configure `libffi` to use the same directory as JNA for its temporary
files if they are needed.

Closes #18272
Closes #73309
Closes #74545
Closes #77014
Closes #77053
Relates #77285

Co-authored-by: Rory Hunter <roryhunter2@gmail.com>
2021-11-15 08:18:58 +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
Tim Vernum
71c702263b
Check whether stdout is a real console (#79882)
Adds a new "ConsoleLoader" that uses jANSI in a separate classloader
to determine whether standard output is a real console (that is, not
redirected to a file or /dev/null, etc)

Also updates security auto-configuration to only print out credentials
when there is a console.
2021-10-28 14:06:33 +11:00
Mark Vieira
26c86871fc
Require Java 17 for running Elasticsearch (#79873) 2021-10-27 08:23:03 -07:00
Mark Vieira
12ad399c48 Reformat Elasticsearch source 2021-10-27 08:19:51 -07:00
Ioannis Kakavas
874180efb1
CLI tool to reconfigure nodes to enroll (#79690)
This change introduces a CLI tool that can be run directly after
installation time in packaged installations, to allow for a node
that was auto-configured to be the initial node of a cluster during
installation ( default installation behavior) to be reconfigured
to join an existing cluster, using an enrollment token.
The use of this tool presumes that the user has the
appropriate permissions to read/write to the installation dirs and
that this node has not been yet started, i.e. this tool is run
directly after installation. It is destructive, as it removes
existing security auto-configuration, and as such it requires an
explicit verification from the user.

This is a follow-up to #7718.
2021-10-27 13:29:52 +03:00
Ioannis Kakavas
5d3b6bf2f7
Allow node to enroll to cluster on startup (#77718)
The functionality to enroll a new node to a cluster was
introduced in #77292 as a CLI tool. This change replaces this
CLI tool with the option to trigger the enrollment functionality 
on startup of elasticsearch via a named argument that can be 
passed to the elasticsearch startup script (--enrollment-token)
so that the users that want to enroll a node to a cluster can do 
this with one command instead of two. 

In a followup PR we are introducing a CLI tool version of this
functionality, that can be used to reconfigure packaged
installations.
2021-10-27 08:13:49 +03:00
Ioannis Kakavas
0eb2baa07d
CLI tool to (re)set users password (#79709)
This change introduces a new CLI tool that can be used to set and
reset the password of all the built-in users and users in the native
realm in Elasticsearch. It depends on the file realm being enabled
(which it is, by default) and can (re)set one built-in user password at a time.
It removes the previously introduced elasticsearch-reset-elastic-password
and elasticsearch-reset-kibana-system-password as their functionality is
covered by this new tool.
2021-10-26 07:57:18 +03:00
Ioannis Kakavas
c5ea5d3ed3
Edit the autoconfiguration output for packages (#79687)
Slight rewording in order to align the output format with that of
archives and docker
2021-10-26 06:24:26 +03:00