Skip to content

Commit

Permalink
Throw an error when --es.use-ilm is set without --es.use-aliases (#2820)
Browse files Browse the repository at this point in the history
Signed-off-by: santosh <[email protected]>
  • Loading branch information
bhiravabhatla authored Feb 20, 2021
1 parent cc3c8e3 commit bfd17cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func createSpanReader(
cfg config.ClientBuilder,
archive bool,
) (spanstore.Reader, error) {
if cfg.GetUseILM() && !cfg.GetUseReadWriteAliases() {
return nil, fmt.Errorf("--es.use-ilm must always be used in conjunction with --es.use-aliases to ensure ES writers and readers refer to the single index mapping")
}
return esSpanStore.NewSpanReader(esSpanStore.SpanReaderParams{
Client: client,
Logger: logger,
Expand All @@ -161,6 +164,9 @@ func createSpanWriter(
) (spanstore.Writer, error) {
var tags []string
var err error
if cfg.GetUseILM() && !cfg.GetUseReadWriteAliases() {
return nil, fmt.Errorf("--es.use-ilm must always be used in conjunction with --es.use-aliases to ensure ES writers and readers refer to the single index mapping")
}
if tags, err = cfg.TagKeysAsFields(); err != nil {
logger.Error("failed to get tag keys", zap.Error(err))
return nil, err
Expand Down
16 changes: 16 additions & 0 deletions plugin/storage/es/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ func TestElasticsearchTagsFileDoNotExist(t *testing.T) {
assert.Nil(t, r)
}

func TestElasticsearchILMUsedWithoutReadWriteAliases(t *testing.T) {
f := NewFactory()
mockConf := &mockClientBuilder{}
mockConf.UseILM = true
f.primaryConfig = mockConf
f.archiveConfig = mockConf
assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop()))
w, err := f.CreateSpanWriter()
require.EqualError(t, err, "--es.use-ilm must always be used in conjunction with --es.use-aliases to ensure ES writers and readers refer to the single index mapping")
assert.Nil(t, w)

r, err := f.CreateSpanReader()
require.EqualError(t, err, "--es.use-ilm must always be used in conjunction with --es.use-aliases to ensure ES writers and readers refer to the single index mapping")
assert.Nil(t, r)
}

func TestTagKeysAsFields(t *testing.T) {
tests := []struct {
path string
Expand Down

0 comments on commit bfd17cd

Please sign in to comment.