Skip to content

Commit befdce1

Browse files
committed
Move file-based discovery to core
Today we support a static list of seed hosts in core Elasticsearch, and allow a dynamic list of seed hosts to be provided via a file using the `discovery-file` plugin. In fact the ability to provide a dynamic list of seed hosts is increasingly useful in containerized environments, so this change moves this functionality to core Elasticsearch to avoid the need for a plugin. For BWC purposes the plugin still exists, but does nothing more than issue a warning when it is used. Furthermore, in order to start up nodes in integration tests we currently assign a known port to each node before startup, which unfortunately sometimes fails if another process grabs the selected port in the meantime. By moving the `discovery-file` functionality into the core product we can use it to avoid this race. Relates elastic#29244 Closes elastic#33030
1 parent 4910918 commit befdce1

File tree

11 files changed

+236
-198
lines changed

11 files changed

+236
-198
lines changed

plugins/discovery-file/config/discovery-file/unicast_hosts.txt renamed to distribution/src/config/discovery-file/unicast_hosts.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
# mechanism. This file should contain one entry per line, where an entry is a
44
# host/port combination. The host and port should be separated by a `:`. If
55
# the port is left off, a default port of 9300 is assumed. For example, if the
6-
# cluster has three nodes that participate in the discovery process:
7-
# (1) 66.77.88.99 running on port 9300 (2) 66.77.88.100 running on port 9305
8-
# and (3) 66.77.88.99 running on port 10005, then this file should contain the
6+
# cluster has three nodes that participate in the discovery process: (1)
7+
# 66.77.88.99 running on port 9300 (2) 66.77.88.100 running on port 9305 and
8+
# (3) 66.77.88.99 running on port 10005, then this file should contain the
99
# following text:
1010
#
1111
#10.10.10.5
1212
#10.10.10.6:9305
1313
#10.10.10.5:10005
1414
#
15-
# For IPv6 addresses, make sure to put a bracket around the host part of the address,
16-
# for example: [2001:cdba:0000:0000:0000:0000:3257:9652]:9301 (where 9301 is the port).
15+
# For IPv6 addresses, make sure to put a bracket around the host part of the
16+
# address, for example: [2001:cdba:0000:0000:0000:0000:3257:9652]:9301 (where
17+
# 9301 is the port).
18+
#
19+
# NOTE: all lines starting with a `#` are comments, and comments must exist on
20+
# lines of their own (i.e. comments cannot begin in the middle of a line)
21+
#
22+
# NOTE: Set `discovery.zen.hosts_provider: file` to enable file-based discovery
23+
# and use this file. If this setting is not set then Elasticsearch will not
24+
# read this file.
1725
#
18-
# NOTE: all lines starting with a `#` are comments, and comments must exist
19-
# on lines of their own (i.e. comments cannot begin in the middle of a line)
20-
#

docs/plugins/discovery-file.asciidoc

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,10 @@
11
[[discovery-file]]
22
=== File-Based Discovery Plugin
33

4-
The file-based discovery plugin uses a list of hosts/ports in a `unicast_hosts.txt` file
5-
in the `config/discovery-file` directory for unicast discovery.
4+
The functionality provided by the `discovery-file` plugin is now available in
5+
Elasticsearch without requiring a plugin. This plugin still exists for backwards
6+
compatibility, but it no longer does anything and will be removed in a future
7+
version.
68

79
:plugin_name: discovery-file
810
include::install_remove.asciidoc[]
9-
10-
[[discovery-file-usage]]
11-
[float]
12-
==== Using the file-based discovery plugin
13-
14-
The file-based discovery plugin provides the ability to specify the
15-
unicast hosts list through a simple `unicast_hosts.txt` file that can
16-
be dynamically updated at any time. To enable, add the following in `elasticsearch.yml`:
17-
18-
[source,yaml]
19-
----
20-
discovery.zen.hosts_provider: file
21-
----
22-
23-
This plugin simply provides a facility to supply the unicast hosts list for
24-
zen discovery through an external file that can be updated at any time by a side process.
25-
26-
For example, this gives a convenient mechanism for an Elasticsearch instance
27-
that is run in docker containers to be dynamically supplied a list of IP
28-
addresses to connect to for zen discovery when those IP addresses may not be
29-
known at node startup.
30-
31-
Note that the file-based discovery plugin is meant to augment the unicast
32-
hosts list in `elasticsearch.yml` (if specified), not replace it. Therefore,
33-
if there are valid unicast host entries in `discovery.zen.ping.unicast.hosts`,
34-
they will be used in addition to those supplied in `unicast_hosts.txt`.
35-
36-
Anytime a change is made to the `unicast_hosts.txt` file, even as Elasticsearch
37-
continues to run, the new changes will be picked up by the plugin and the
38-
new hosts list will be used for the next pinging round for master election.
39-
40-
Upon installation of the plugin, a default `unicast_hosts.txt` file will
41-
be found in the `$CONFIG_DIR/discovery-file` directory. This default file
42-
will contain some comments about what the file should contain. All comments
43-
for this file must appear on their lines starting with `#` (i.e. comments
44-
cannot start in the middle of a line).
45-
46-
[[discovery-file-format]]
47-
[float]
48-
==== unicast_hosts.txt file format
49-
50-
The format of the file is to specify one unicast host entry per line.
51-
Each unicast host entry consists of the host (host name or IP address) and
52-
an optional transport port number. If the port number is specified, is must
53-
come immediately after the host (on the same line) separated by a `:`.
54-
If the port number is not specified, a default value of 9300 is used.
55-
56-
For example, this is an example of `unicast_hosts.txt` for a cluster with
57-
four nodes that participate in unicast discovery, some of which are not
58-
running on the default port:
59-
60-
[source,txt]
61-
----------------------------------------------------------------
62-
10.10.10.5
63-
10.10.10.6:9305
64-
10.10.10.5:10005
65-
# an IPv6 address
66-
[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:9301
67-
----------------------------------------------------------------
68-
69-
Host names are allowed instead of IP addresses (similar to
70-
`discovery.zen.ping.unicast.hosts`), and IPv6 addresses must be
71-
specified in brackets with the port coming after the brackets.

0 commit comments

Comments
 (0)