Skip to content

Pass the settings from non-overruling providers to overruling ones. #115397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kkrik-es
Copy link
Contributor

@kkrik-es kkrik-es commented Oct 23, 2024

This is needed for chaining providers, e.g. logsdb provider setting the index mode, then the synthetic source provider deciding to downgrade to stored source.

The plan is to initially cover just index create, to unblock testing, then separately refactor the index setting merging logic to a dedicated class and use it in other places too.

@kkrik-es kkrik-es self-assigned this Oct 23, 2024
@kkrik-es kkrik-es marked this pull request as ready for review October 23, 2024 12:02
@kkrik-es kkrik-es requested review from martijnvg and lkts October 23, 2024 12:02
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@kkrik-es kkrik-es added auto-backport Automatically create backport pull requests when merged v8.17.0 labels Oct 23, 2024
@kkrik-es kkrik-es changed the title Feed the settings from non-overruling providers to overruling ones. Pass the settings from non-overruling providers to overruling ones. Oct 23, 2024
Copy link
Contributor

@lkts lkts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two questions but overall LGTM.


// Feed the settings generated by non-overruling to overruling setting providers,
// along with template and request settings.
final Settings templateAndRequestAndProviderSettings = settingsBuilder.put(additionalIndexSettings.build()).build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the order matter here? I mean the fact that we apply additionalIndexSettings after request.settings().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, we'd need to filter conflicting ones. I'll add something if we decide to proceed with this.

templateAndRequestAndProviderSettings,
combinedTemplateMappings
);
additionalIndexSettings.put(newAdditionalSettings);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this line?

Copy link
Contributor Author

@kkrik-es kkrik-es Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, additionalIndexSettings contains all provided settings and it's used below.

@lkts
Copy link
Contributor

lkts commented Oct 23, 2024

I like the simplicity of #115437 but it is based on our assumptions of how the code is working. IMO this approach is more robust and given that it does not add much complexity i am in favour of this.

@kkrik-es
Copy link
Contributor Author

Hey @dakrone, we wanted to get your take on this.. We have cases where the output of one index settings provider is used as input for another one (chaining). The particular blocker for logsdb was addressed in #115437, so we were wondering if we should take the time to pursue a more robust solution.

In this PR, I'm introducing two phases, with providers marked as non-overruling providing inputs to overruling ones. This covers our case and any pair of chained providers, but can get us so far. Another option is to introduce a priority per provider and start from lower-priority ones, passing their outputs to the following ones. We'd need to see how to efficiently create Settings objects on each step, without copying all request and template settings each time.

I was wondering if you could take some time to look at this and provide guidance on how you'd rather proceed. As mentioned, this is not high priority as we have a workaround.

@dakrone
Copy link
Member

dakrone commented Oct 24, 2024

We have cases where the output of one index settings provider is used as input for another one (chaining).

Can you elaborate a little bit on why these can't be put into a single index provider? If at all possible, it feels cleaner to me to have each provider be independent from the other, so that we don't have to have ordering or priorities at all.

@kkrik-es
Copy link
Contributor Author

We have cases where the output of one index settings provider is used as input for another one (chaining).

Can you elaborate a little bit on why these can't be put into a single index provider? If at all possible, it feels cleaner to me to have each provider be independent from the other, so that we don't have to have ordering or priorities at all.

That can certainly work, though it would have somewhat confusing semantics. Each provider can apply on its own, and they produce different settings (logsdb index mode vs stored source mode). There's a cross-section where they both apply (based on the index name logs-*-*) and this is the only case where they need to be combined.

@dakrone
Copy link
Member

dakrone commented Oct 25, 2024

Martijn and I talked a little bit about this offline. I think my preference would go in order of:

  1. Put everything that is dependent on other pieces into a single provider.
  2. Formalize the "pre" providers and the "post" providers by having them be separate interfaces (rather than using an overrides method as an indicator).
  3. Implement priorities for explicit ordering of the providers.

Of course, this is just my own preference, not something we necessarily have to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >non-issue :StorageEngine/Logs You know, for Logs Team:StorageEngine v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants