Skip to content

Commit

Permalink
Ilm disable template (#3610)
Browse files Browse the repository at this point in the history
* useILM will prevent index template creation

The index template should be created by es-rollover. Without this, it
was mandatory to use --es.create-index-templates=false with
--es.use-ilm, otherwise it would override the index template with an
empty lifecycle.name thus preventing the rollover to work

Signed-off-by: Raphael Bizos <[email protected]>

* fixing ILM test

Signed-off-by: Raphael Bizos <[email protected]>

* Adding a comment for ILM and index creation

Signed-off-by: Raphael Bizos <[email protected]>
  • Loading branch information
rbizos authored Apr 1, 2022
1 parent 2a66711 commit bb042cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ func createSpanWriter(
Archive: archive,
UseReadWriteAliases: cfg.GetUseReadWriteAliases(),
})
if cfg.IsCreateIndexTemplates() {

// Creating a template here would conflict with the one created for ILM resulting to no index rollover
if cfg.IsCreateIndexTemplates() && !cfg.GetUseILM() {
err := writer.CreateTemplates(spanMapping, serviceMapping, cfg.GetIndexPrefix())
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions plugin/storage/es/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ func TestCreateTemplateError(t *testing.T) {
assert.Error(t, err, "template-error")
}

func TestILMDisableTemplateCreation(t *testing.T) {
f := NewFactory()
f.primaryConfig = &mockClientBuilder{createTemplateError: errors.New("template-error"), Configuration: escfg.Configuration{Enabled: true, UseILM: true, UseReadWriteAliases: true, CreateIndexTemplates: true}}
f.archiveConfig = &mockClientBuilder{}
err := f.Initialize(metrics.NullFactory, zap.NewNop())
require.NoError(t, err)
_, err = f.CreateSpanWriter()
assert.Nil(t, err) // as the createTemplate is not called, CreateSpanWriter should not return an error
}

func TestArchiveDisabled(t *testing.T) {
f := NewFactory()
f.archiveConfig = &mockClientBuilder{Configuration: escfg.Configuration{Enabled: false}}
Expand Down

0 comments on commit bb042cc

Please sign in to comment.