Skip to content

Commit a2a1da6

Browse files
CGamesPlaysynhershko
authored andcommitted
install given plugins in bootstrap node
Resolves #1078 Signed-off-by: Ryan Patterson <ryan@bigdataboutique.com>
1 parent 20677cb commit a2a1da6

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

opensearch-operator/pkg/builders/cluster.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,12 @@ func NewBootstrapPod(
10101010

10111011
startUpCommand := "./opensearch-docker-entrypoint.sh"
10121012

1013-
pluginslist := helpers.RemoveDuplicateStrings(cr.Spec.Bootstrap.PluginsList)
1013+
// Use General.PluginsList by default, override with Bootstrap.PluginsList if set
1014+
pluginslist := cr.Spec.General.PluginsList
1015+
if len(cr.Spec.Bootstrap.PluginsList) > 0 {
1016+
pluginslist = cr.Spec.Bootstrap.PluginsList
1017+
}
1018+
pluginslist = helpers.RemoveDuplicateStrings(pluginslist)
10141019
mainCommand := helpers.BuildMainCommand("./bin/opensearch-plugin", pluginslist, true, startUpCommand)
10151020
pod := &corev1.Pod{
10161021
ObjectMeta: metav1.ObjectMeta{

opensearch-operator/pkg/builders/cluster_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,49 @@ var _ = Describe("Builders", func() {
671671
Expect(expected).To(Equal(actual))
672672
})
673673

674+
It("should inherit General.PluginsList when Bootstrap.PluginsList is not set", func() {
675+
clusterObject := ClusterDescWithVersion("2.2.1")
676+
pluginA := "repository-s3"
677+
pluginB := "analysis-icu"
678+
679+
clusterObject.Spec.General.PluginsList = []string{pluginA, pluginB}
680+
// Bootstrap.PluginsList is not set
681+
result := NewBootstrapPod(&clusterObject, nil, nil)
682+
683+
actual := result.Spec.Containers[0].Command
684+
Expect(len(actual)).To(Equal(3))
685+
Expect(actual[2]).To(ContainSubstring(pluginA))
686+
Expect(actual[2]).To(ContainSubstring(pluginB))
687+
})
688+
689+
It("should override General.PluginsList with Bootstrap.PluginsList when explicitly set", func() {
690+
clusterObject := ClusterDescWithVersion("2.2.1")
691+
generalPlugin := "repository-s3"
692+
bootstrapPluginA := "custom-plugin-a"
693+
bootstrapPluginB := "custom-plugin-b"
694+
695+
clusterObject.Spec.General.PluginsList = []string{generalPlugin}
696+
clusterObject.Spec.Bootstrap.PluginsList = []string{bootstrapPluginA, bootstrapPluginB}
697+
result := NewBootstrapPod(&clusterObject, nil, nil)
698+
699+
// Should use Bootstrap.PluginsList, not General.PluginsList
700+
actual := result.Spec.Containers[0].Command
701+
Expect(len(actual)).To(Equal(3))
702+
Expect(actual[2]).To(ContainSubstring(bootstrapPluginA))
703+
Expect(actual[2]).To(ContainSubstring(bootstrapPluginB))
704+
Expect(actual[2]).NotTo(ContainSubstring(generalPlugin))
705+
})
706+
707+
It("should use no plugins when both General.PluginsList and Bootstrap.PluginsList are empty", func() {
708+
clusterObject := ClusterDescWithVersion("2.2.1")
709+
// Neither list is set
710+
result := NewBootstrapPod(&clusterObject, nil, nil)
711+
712+
actual := result.Spec.Containers[0].Command
713+
Expect(len(actual)).To(Equal(3))
714+
Expect(actual[2]).To(Equal("./opensearch-docker-entrypoint.sh"))
715+
})
716+
674717
It("should use PVC for data volume instead of emptyDir", func() {
675718
clusterObject := ClusterDescWithVersion("2.2.1")
676719
result := NewBootstrapPod(&clusterObject, nil, nil)

0 commit comments

Comments
 (0)