From 3b49a20a6bb6192fdb655f028452162771d91891 Mon Sep 17 00:00:00 2001 From: Raphael Bizos Date: Thu, 24 Mar 2022 16:22:37 +0100 Subject: [PATCH 1/3] 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 --- plugin/storage/es/factory.go | 2 +- plugin/storage/es/factory_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index dea1ad6aff3..4dee37a3c5d 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -199,7 +199,7 @@ func createSpanWriter( Archive: archive, UseReadWriteAliases: cfg.GetUseReadWriteAliases(), }) - if cfg.IsCreateIndexTemplates() { + 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..742524b2ac3 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -185,6 +185,17 @@ 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: false, UseReadWriteAliases: true, CreateIndexTemplates: true}} + f.archiveConfig = &mockClientBuilder{} + err := f.Initialize(metrics.NullFactory, zap.NewNop()) + require.NoError(t, err) + w, err := f.CreateSpanWriter() + assert.Nil(t, w) + 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}} From 77c32ffa6b7e6d29ad0e014e5a8ec7b3cffd3b36 Mon Sep 17 00:00:00 2001 From: Raphael Bizos Date: Wed, 30 Mar 2022 14:13:44 +0200 Subject: [PATCH 2/3] fixing ILM test Signed-off-by: Raphael Bizos --- plugin/storage/es/factory_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 742524b2ac3..a5d7b71d299 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -187,12 +187,11 @@ func TestCreateTemplateError(t *testing.T) { func TestILMDisableTemplateCreation(t *testing.T) { f := NewFactory() - f.primaryConfig = &mockClientBuilder{createTemplateError: errors.New("template-error"), Configuration: escfg.Configuration{Enabled: true, UseILM: false, UseReadWriteAliases: true, CreateIndexTemplates: true}} + 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) - w, err := f.CreateSpanWriter() - assert.Nil(t, w) + _, err = f.CreateSpanWriter() assert.Nil(t, err) // as the createTemplate is not called, CreateSpanWriter should not return an error } From b63574a3c966e534ae8baaf635e6093b6b6e48f5 Mon Sep 17 00:00:00 2001 From: Raphael Bizos Date: Fri, 1 Apr 2022 11:24:13 +0200 Subject: [PATCH 3/3] Adding a comment for ILM and index creation Signed-off-by: Raphael Bizos --- plugin/storage/es/factory.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index 4dee37a3c5d..7878d022016 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -199,6 +199,8 @@ func createSpanWriter( Archive: archive, UseReadWriteAliases: cfg.GetUseReadWriteAliases(), }) + + // 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 {