diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index dea1ad6aff3..7878d022016 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -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 diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 525dc9a29dc..a5d7b71d299 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -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}}