Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -59,7 +59,6 @@ var (
)

// NewPrepareFSInitContainer creates an init container to handle things such as:
// - plugins installation
// - configuration changes
// Modified directories and files are meant to be persisted for reuse in the actual ES container.
// This container does not need to be privileged.
Expand All @@ -76,7 +75,6 @@ func NewPrepareFSInitContainer(
certificatesVolumeMount.MountPath = "/mnt/elastic-internal/transport-certificates"

script, err := RenderScriptTemplate(TemplateParams{
Plugins: defaultInstalledPlugins,
SharedVolumes: PrepareFsSharedVolumes,
LinkedFiles: linkedFiles,
ChownToElasticsearch: []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ import (
"html/template"
)

// List of plugins to be installed on the ES instance
var defaultInstalledPlugins = []string{
"repository-s3", // S3 snapshots
"repository-gcs", // gcp snapshots
}

// TemplateParams are the parameters manipulated in the scriptTemplate
type TemplateParams struct {
// Plugins is a list of plugins to install
Plugins []string
// SharedVolumes are directories to persist in shared volumes
SharedVolumes SharedVolumeArray
// LinkedFiles are files to link individually
Expand All @@ -42,12 +34,7 @@ func RenderScriptTemplate(params TemplateParams) (string, error) {
// in the prepare-fs init container before ES starts
var scriptTemplate = template.Must(template.New("").Parse(
`#!/usr/bin/env bash -eu

ES_DIR="/usr/share/elasticsearch"
CONFIG_DIR=$ES_DIR/config
PLUGIN_BIN=$ES_DIR/bin/elasticsearch-plugin
KEYSTORE_BIN=$ES_DIR/bin/elasticsearch-keystore


# compute time in seconds since the given start time
function duration() {
local start=$1
Expand All @@ -63,23 +50,6 @@ var scriptTemplate = template.Must(template.New("").Parse(

echo "Starting init script"

######################
# Plugins #
######################

plugins_start=$(date +%s)
# Install extra plugins
{{range .Plugins}}
echo "Installing plugin {{.}}"
# Using --batch accepts any user prompt (y/n)
$PLUGIN_BIN install --batch {{.}}
{{end}}

echo "Installed plugins:"
$PLUGIN_BIN list

echo "Plugins installation duration: $(duration $plugins_start) sec."

######################
# Config linking #
######################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func TestRenderScriptTemplate(t *testing.T) {
{
name: "Standard script rendering",
params: TemplateParams{
Plugins: defaultInstalledPlugins,
SharedVolumes: PrepareFsSharedVolumes,
LinkedFiles: LinkedFilesArray{
Array: []LinkedFile{
Expand All @@ -29,8 +28,6 @@ func TestRenderScriptTemplate(t *testing.T) {
Target: "/usr/share/elasticsearch/users"}}},
},
wantSubstr: []string{
"$PLUGIN_BIN install --batch repository-s3",
"$PLUGIN_BIN install --batch repository-gcs",
"mv /usr/share/elasticsearch/config/* /mnt/elastic-internal/elasticsearch-config-local/",
"mv /usr/share/elasticsearch/bin/* /mnt/elastic-internal/elasticsearch-bin-local/",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need these 2 anymore (see above)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I think I need to revert the last commit and restore the plugin mount again. Otherwise it will be really tricky for users to make this work correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm you're right.

"mv /usr/share/elasticsearch/plugins/* /mnt/elastic-internal/elasticsearch-plugins-local/",
Expand Down