Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce declarative plugin management #77544

Merged
merged 117 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
6eda87c
Proof of concept for declarative plugin management
pugnascotia Jun 8, 2021
a57e8f4
More work
pugnascotia Jun 24, 2021
c45199e
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Aug 3, 2021
264012f
WIP
pugnascotia Aug 5, 2021
f1e01e0
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Aug 26, 2021
1a61bb5
Get basic sync working again, and fix existing tests
pugnascotia Aug 31, 2021
08ed84e
Progress
pugnascotia Sep 2, 2021
89b1f19
Tests
pugnascotia Sep 3, 2021
5db7f0b
More tests
pugnascotia Sep 3, 2021
8174d07
More tests
pugnascotia Sep 5, 2021
fc53fbb
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 6, 2021
4b53a04
Sync command can use the plugin archive
pugnascotia Sep 6, 2021
b541732
Remove plugin wrapper tool since it's redundant
pugnascotia Sep 6, 2021
4395902
Test plugins sync in Docker cloud-ess
pugnascotia Sep 7, 2021
91c1ce2
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 7, 2021
e66ab4f
Rename default plugins config to deactivate it by default
pugnascotia Sep 7, 2021
534e434
Tweaks
pugnascotia Sep 7, 2021
3a6e4df
Remove call to plugins sync from Windows startup file
pugnascotia Sep 7, 2021
11f2004
Tweaks and Javadoc
pugnascotia Sep 7, 2021
816bae1
Strip out per-plugin proxies, fix checks
pugnascotia Sep 7, 2021
8122c1e
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 8, 2021
40b7033
Simplify proxy code
pugnascotia Sep 8, 2021
db7af8f
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 8, 2021
612979b
Simplify proxy configuration
pugnascotia Sep 9, 2021
979d0a3
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 9, 2021
f0a5fbd
Forid plugin ID differing in the downloaded properties
pugnascotia Sep 9, 2021
05a350f
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 10, 2021
9829056
Add example plugins config as configuration file in rpm / deb
pugnascotia Sep 10, 2021
1e1ffc7
Tweak checkstyle comment
pugnascotia Sep 14, 2021
8df977c
Rename url field to location
pugnascotia Sep 14, 2021
7d1d210
Change prefix of plugin archive dir env var
pugnascotia Sep 14, 2021
91af84e
Extract constant
pugnascotia Sep 14, 2021
c735a0a
Rename PluginsManifest to PluginsConfig
pugnascotia Sep 14, 2021
94c15e9
Swap URI for URL
pugnascotia Sep 14, 2021
6e1a68b
Include exception as cause when parsing the config
pugnascotia Sep 14, 2021
7282c7d
URI tweak
pugnascotia Sep 14, 2021
524033a
Make the Docker layer cache usable for snapshot builds
pugnascotia Sep 14, 2021
8337588
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 14, 2021
ffbb4d3
Begin moving plugin sync code to bootstrap process
pugnascotia Sep 16, 2021
a779dfa
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 21, 2021
606a138
Rearrange code
pugnascotia Sep 21, 2021
cbed833
Tweak ES policy for jackson-databind
pugnascotia Sep 21, 2021
a35dbf6
Use xcontent for parsing instead of jackson
pugnascotia Sep 23, 2021
614be7c
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 23, 2021
83192eb
Fix Docker again
pugnascotia Sep 23, 2021
8f822b0
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 23, 2021
a09c13f
WIP
pugnascotia Sep 23, 2021
1655aa3
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 23, 2021
71efa11
Disable BouncyCastle in server until I figure out the break
pugnascotia Sep 23, 2021
7c222f5
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 24, 2021
a67aa8b
Restore bc fips jars in server
pugnascotia Sep 24, 2021
0328678
Tweaks
pugnascotia Sep 24, 2021
13433ab
Refactoring
pugnascotia Sep 24, 2021
cbba285
Only use PluginsManager with Docker distributions
pugnascotia Sep 24, 2021
77f3787
Update :x-pack:plugin:identity-provider:thirdPartyAudit exclusions
pugnascotia Sep 24, 2021
22028bf
WIP to load plugin-cli jars
pugnascotia Sep 28, 2021
8abde31
Abstract a logging interface for plugin actions
pugnascotia Sep 28, 2021
7fd932d
Abstract a logging interface for plugin actions
pugnascotia Sep 28, 2021
d77e645
Use plugin-cli classes via a classloader
pugnascotia Sep 28, 2021
5ee9d71
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 28, 2021
b897a58
Revert some changes
pugnascotia Sep 28, 2021
7b6325b
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Sep 28, 2021
8c2fa96
Fixes
pugnascotia Sep 28, 2021
494efae
Refactor RemovePluginAction to be more like a library
pugnascotia Sep 29, 2021
0319a20
Move plugin action classes to a sub-package
pugnascotia Sep 29, 2021
db9e0a8
Revert logging abstraction
pugnascotia Sep 30, 2021
a6f51b1
Merge remote-tracking branch 'upstream/master' into 70219-refactor-pl…
pugnascotia Sep 30, 2021
87bd95e
Tweaks
pugnascotia Sep 30, 2021
b9d78ac
Move exit code logic for installing plugins to the command class
pugnascotia Sep 30, 2021
7432e46
Merge branch '70219-refactor-plugin-actions-further' into 70219-decla…
pugnascotia Sep 30, 2021
4e09190
Fixes after merging
pugnascotia Sep 30, 2021
9ceb944
Tidy up plugin install logging in headless mode
pugnascotia Sep 30, 2021
ea6d5e6
Tweaks
pugnascotia Sep 30, 2021
ba73e5f
Spotless
pugnascotia Sep 30, 2021
e84d0a1
Revert to previous exceptions scheme
pugnascotia Oct 1, 2021
670227d
Move PluginSecurity to action subpackage
pugnascotia Oct 1, 2021
eb80ce2
Merge branch '70219-refactor-plugin-actions-further' into 70219-decla…
pugnascotia Oct 1, 2021
cd90a19
Move sync code to plugins cli action package
pugnascotia Oct 1, 2021
bc2358e
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Oct 1, 2021
b6bbeba
Moving code around
pugnascotia Oct 1, 2021
c48c712
Tweaks and fixes
pugnascotia Oct 1, 2021
9770a55
Cleanups
pugnascotia Oct 1, 2021
0ec9923
Fix forbidden API
pugnascotia Oct 1, 2021
ea3aaa8
Fix license header
pugnascotia Oct 1, 2021
e5dc33b
Move files to the correct new place
pugnascotia Oct 6, 2021
f051247
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Oct 7, 2021
ddbd26b
Fix tests
pugnascotia Oct 7, 2021
897a54f
Tweaks
pugnascotia Oct 7, 2021
215463e
Improve plugin CLI qa tests
pugnascotia Oct 7, 2021
3aabee8
Add test for syncing plugins via configured proxy
pugnascotia Oct 8, 2021
367cac1
Refactor
pugnascotia Oct 8, 2021
0d65a30
Don't use curl, and also test system proxy settings
pugnascotia Oct 8, 2021
d39682d
Cleanups and docs
pugnascotia Oct 8, 2021
9aa6b6f
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Oct 11, 2021
08174bc
Add unit testing
pugnascotia Oct 11, 2021
8c65b1d
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Oct 13, 2021
8dd64da
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Oct 14, 2021
3b6c077
Formatting
pugnascotia Oct 14, 2021
fb3ac3f
Test fix
pugnascotia Oct 14, 2021
673b6ea
Reformat everything before merge
pugnascotia Nov 8, 2021
bfdad33
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Nov 8, 2021
dfd6ed5
Update example plugins config
pugnascotia Nov 8, 2021
42e4110
Move plugin actions back to the cli sub-package
pugnascotia Nov 9, 2021
ef7c378
Use Build.CURRENT instead of referencing the sys prop directly
pugnascotia Nov 9, 2021
c8f5c5e
Rename SyncPluginsProvider to PluginsSynchronizer
pugnascotia Nov 9, 2021
45e5274
Move plugins config cache to plugins dir
pugnascotia Nov 9, 2021
bdaa359
Write cached config in CBOR, not YAML
pugnascotia Nov 9, 2021
435fe2d
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Nov 9, 2021
9ca2427
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Nov 10, 2021
df52770
Test Docker + plugins by including analysis-icu
pugnascotia Nov 11, 2021
6f3df48
Try re-enabling PluginCliTests
pugnascotia Nov 11, 2021
de516de
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Nov 11, 2021
d46f0bc
Fix test ordering
pugnascotia Nov 11, 2021
8f8c4a1
Try to fix dependencies
pugnascotia Nov 11, 2021
78f6e5b
Another tweak
pugnascotia Nov 11, 2021
2451c52
Merge remote-tracking branch 'upstream/master' into 70219-declarative…
pugnascotia Nov 11, 2021
6eea9a1
Disable PluginCliTests again
pugnascotia Nov 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* build/distributions/local
* */
import org.elasticsearch.gradle.Architecture
import org.elasticsearch.gradle.VersionProperties

// gradle has an open issue of failing applying plugins in
// precompiled script plugins (see https://github.com/gradle/gradle/issues/17004)
Expand All @@ -29,6 +30,6 @@ tasks.register('localDistro', Sync) {
from(elasticsearch_distributions.local)
into("build/distribution/local")
doLast {
logger.lifecycle("Elasticsearch distribution installed to ${destinationDir}.")
logger.lifecycle("Elasticsearch distribution installed to ${destinationDir}/elasticsearch-${VersionProperties.elasticsearch}")
pugnascotia marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void apply(Project project) {
Map<String, TaskProvider<?>> versionTasks = versionTasks(project, "destructiveDistroUpgradeTest");
TaskProvider<Task> destructiveDistroTest = project.getTasks().register("destructiveDistroTest");

// Configuration examplePlugin = configureExamplePlugin(project);
Configuration examplePlugin = configureExamplePlugin(project);

List<TaskProvider<Test>> windowsTestTasks = new ArrayList<>();
Map<ElasticsearchDistributionType, List<TaskProvider<Test>>> linuxTestTasks = new HashMap<>();
Expand All @@ -114,11 +114,12 @@ public void apply(Project project) {
TaskProvider<?> depsTask = project.getTasks().register(taskname + "#deps");
// explicitly depend on the archive not on the implicit extracted distribution
depsTask.configure(t -> t.dependsOn(distribution.getArchiveDependencies()));
depsTask.configure(t -> t.dependsOn(examplePlugin.getDependencies()));
depsTasks.put(taskname, depsTask);
TaskProvider<Test> destructiveTask = configureTestTask(project, taskname, distribution, t -> {
t.onlyIf(t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable);
addDistributionSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath);
// addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString());
addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString());
t.exclude("**/PackageUpgradeTests.class");
}, depsTask);

Expand Down Expand Up @@ -314,7 +315,7 @@ private static Configuration configureExamplePlugin(Project project) {
Configuration examplePlugin = project.getConfigurations().create(EXAMPLE_PLUGIN_CONFIGURATION);
examplePlugin.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE);
DependencyHandler deps = project.getDependencies();
deps.add(EXAMPLE_PLUGIN_CONFIGURATION, deps.create("org.elasticsearch.examples:custom-settings:1.0.0-SNAPSHOT"));
deps.add(EXAMPLE_PLUGIN_CONFIGURATION, deps.project(Map.of("path", ":plugins:analysis-icu", "configuration", "zip")));
return examplePlugin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<message key="javadoc.missing" value="Types should explain their purpose" />
</module>

<!-- Public methods must have JavaDoc -->
<!-- Check the Javadoc for a method e.g that it has the correct parameters, return type etc -->
<module name="JavadocMethod">
<property name="severity" value="warning"/>
<property name="accessModifiers" value="public"/>
Expand Down
2 changes: 1 addition & 1 deletion distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
*****************************************************************************/
libFiles =
copySpec {
// delay by using closures, since they have not yet been configured, so no jar task exists yet
// Delay by using closures, since they have not yet been configured, so no jar task exists yet.
from(configurations.libs)
into('tools/geoip-cli') {
from(configurations.libsGeoIpCli)
Expand Down
6 changes: 0 additions & 6 deletions distribution/docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ void addBuildDockerContextTask(Architecture architecture, DockerBase base) {
}
// For some reason, the artifact name can differ depending on what repository we used.
rename ~/((?:file|metric)beat)-.*\.tar\.gz$/, "\$1-${VersionProperties.elasticsearch}.tar.gz"

into('bin') {
from(project.projectDir.toPath().resolve('src/docker/cloud')) {
expand([ version: VersionProperties.elasticsearch ])
}
}
}

onlyIf { Architecture.current() == architecture }
Expand Down
11 changes: 7 additions & 4 deletions distribution/docker/src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ RUN sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' bin/elas
find config -type f -exec chmod 0664 {} +

<% if (docker_base == "cloud") { %>
# Preinstall common plugins
# Preinstall common plugins. Note that these are installed as root, meaning the `elasticsearch` user cannot delete them.
COPY repository-s3-${version}.zip repository-gcs-${version}.zip repository-azure-${version}.zip /tmp/
RUN bin/elasticsearch-plugin install --batch \\
RUN bin/elasticsearch-plugin install --batch --verbose \\
file:/tmp/repository-s3-${version}.zip \\
file:/tmp/repository-gcs-${version}.zip \\
file:/tmp/repository-azure-${version}.zip
# Generate a replacement example plugins config that reflects what is actually installed
RUN echo "plugins:" > config/elasticsearch-plugins.example.yml && \\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this example have been copied from the tar distribution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tar distribution does contain an example, but what this code is doing is replacing that example, because for the Cloud and Cloud ESS Docker images, they come with some plugins pre-installed. It's not necessary to do this at all, but it's handy for opting into declarative plugins for testing things out manually.

echo " - id: repository-azure" >> config/elasticsearch-plugins.example.yml && \\
echo " - id: repository-gcs" >> config/elasticsearch-plugins.example.yml && \\
echo " - id: repository-s3" >> config/elasticsearch-plugins.example.yml

<% /* I tried to use `ADD` here, but I couldn't force it to do what I wanted */ %>
COPY filebeat-${version}.tar.gz metricbeat-${version}.tar.gz /tmp/
Expand All @@ -125,8 +130,6 @@ RUN mkdir -p /opt/filebeat /opt/metricbeat && \\

# Add plugins infrastructure
RUN mkdir -p /opt/plugins/archive
COPY bin/plugin-wrapper.sh /opt/plugins
# These are the correct permissions for both the directories and the script
RUN chmod -R 0555 /opt/plugins
<% } %>

Expand Down
1 change: 1 addition & 0 deletions distribution/docker/src/docker/Dockerfile.cloud-ess
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ RUN chmod 0444 /opt/plugins/archive/*
FROM ${base_image}

COPY --from=builder /opt/plugins /opt/plugins
ENV ES_PLUGIN_ARCHIVE_DIR /opt/plugins/archive
34 changes: 0 additions & 34 deletions distribution/docker/src/docker/cloud/plugin-wrapper.sh

This file was deleted.

1 change: 1 addition & 0 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def commonPackageConfig(String type, String architecture) {

// ========= config files =========
configurationFile '/etc/elasticsearch/elasticsearch.yml'
configurationFile '/etc/elasticsearch/elasticsearch-plugins.example.yml'
configurationFile '/etc/elasticsearch/jvm.options'
configurationFile '/etc/elasticsearch/log4j2.properties'
configurationFile '/etc/elasticsearch/role_mapping.yml'
Expand Down
27 changes: 27 additions & 0 deletions distribution/src/config/elasticsearch-plugins.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Rename this file to `elasticsearch-plugins.yml` to use it.
#
# All plugins must be listed here. If you add a plugin to this list and run
pugnascotia marked this conversation as resolved.
Show resolved Hide resolved
# `elasticsearch-plugin sync`, that plugin will be installed. If you remove
# a plugin from this list, that plugin will be removed when Elasticsearch
# next starts.

plugins:
# Each plugin must have an ID. Plugins with only an ID are official plugins and will be downloaded from Elastic.
- id: example-id

# Plugins can be specified by URL (it doesn't have to be HTTP, you could use e.g. `file:`)
- id: example-with-url
location: https://some.domain/path/example4.zip

# Or by maven coordinates:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this means Maven Central right? Should we clarify?

- id: example-with-maven-url
location: org.elasticsearch.plugins:example-plugin:1.2.3

# A proxy can also be configured per-plugin, if necessary
- id: example-with-proxy
location: https://some.domain/path/example.zip
proxy: https://some.domain:1234

# Configures a proxy for all network access. Remove this if you don't need
# to use a proxy.
proxy: https://some.domain:1234
4 changes: 0 additions & 4 deletions distribution/tools/plugin-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ archivesBaseName = 'elasticsearch-plugin-cli'
dependencies {
compileOnly project(":server")
compileOnly project(":libs:elasticsearch-cli")
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
api "org.bouncycastle:bcpg-fips:1.0.4"
api "org.bouncycastle:bc-fips:1.0.2"
testImplementation project(":test:framework")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions distribution/tools/plugin-cli/licenses/jackson-databind-NOTICE.txt

This file was deleted.

Loading