-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[plugin/apm-data]Fallback to ILM for non-dsl-only mode if DSL unavailable #112759
[plugin/apm-data]Fallback to ILM for non-dsl-only mode if DSL unavailable #112759
Conversation
Pinging @elastic/es-data-management (Team:Data Management) |
cfd7e24
to
36d2923
Compare
36d2923
to
21ee4f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like this a lot more than having override files and spreading things across plugins. Looks great.
Should we add YAML REST tests to verify the ILM fallback works correctly?
@axw Added test for checking if ILM files are installed in normal mode. I wanted to also add tests for dsl-only-mode set to |
@lahsivjar what's there looks good. I'd really like to see functional tests that confirm the ILM policies are effective, not just that the component templates exist (checking that the backing indices are managed by ILM would be good enough); but this can also be done in a followup. |
@axw This is a bit more complicated. If there were an older version of the plugin that had ILM it would have been easier, for testing it at the current state we would have to emulate some of the APM integration templates and ILMs... not impossible but would take a bit more effort. I will look into it as a followup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lahsivjar thanks for working on this! I was thinking what if we perform this filtering in the APMIndexTemplateRegistry
? Because this is not yet a well-established solution, but a way to address this in the APM case, I think it would be better to keep it localised in APMIndexTemplateRegistry
. Maybe we override componentTemplates
in that class. What do you think?
x-pack/plugin/apm-data/src/main/resources/component-templates/[email protected]
Outdated
Show resolved
Hide resolved
The
How about we allow overriding for |
@gmarouli I have pushed a fix for scoping logic within the APM plugin (commit ref). It is based on overriding |
I really like this idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like your proposed solution of providing a filter to YamlTemplateRegstry
; however, I find the current way a bit conflicting.
- It has a generic name
shouldLoadTemplate
which is based on the name of the template but then it also needs a boolean (thedslOnlyMode
) which feels a bit random. - If we would extract the
dslOnlyMode
and apply it inlined in the map, we might be limiting the scope of theshouldLoadTemplate
filter.
So, what if we pass the predicate in the constructor:
public YamlTemplateRegistry(
Settings nodeSettings,
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry,
FeatureService featureService
) {
this(nodeSettings, clusterService, threadPool, client, xContentRegistry, featureService, ignored -> true);
}
......
public YamlTemplateRegistry(
Settings nodeSettings,
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry,
FeatureService featureService,
Predicate<String> templateFilter
) {
.....
componentTemplates = Optional.ofNullable(componentTemplateNames)
.orElse(Collections.emptyList())
.stream()
.map(o -> (String) o)
.filter(templateFilter)
.collect(Collectors.toMap(name -> name, name -> loadComponentTemplate(name, version)));
.......
}
And in ApmIndexTemplateRegistry
:
public APMIndexTemplateRegistry(
Settings nodeSettings,
ClusterService clusterService,
ThreadPool threadPool,
Client client,
NamedXContentRegistry xContentRegistry,
FeatureService featureService
) {
super(
nodeSettings,
clusterService,
threadPool,
client,
xContentRegistry,
featureService,
templateName -> DataStreamLifecycle.isDataStreamsLifecycleOnlyMode(clusterService.getSettings()) == false
|| templateName.endsWith("@ilm") == false
);
}
This way the filter is generic enough to be anything we want and the definition of the filter is fully the responsibility of the subclass which allows it to fulfil a variety of use cases.
What do you think?
@gmarouli Makes a lot of sense to me, I have updated the PR. Should be ready for another review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lahsivjar , some small comments and then it's good to go! Great work!
test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Thanks for the detailed review.
test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java
Outdated
Show resolved
Hide resolved
@elasticmachine update branch Updating with main to see if this will fix the ci errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming ci is happy, LGTM :) Thank you for brining this home @lahsivjar , great work!
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
…able (elastic#112759) (cherry picked from commit efdd0c3)
…able (#112759) (#112983) (cherry picked from commit efdd0c3) Authored-by: Vishal Raj <[email protected]>
An alternative PR to #112615 and #112614. With this PR, If a component or index template is named ending
@ilm
then the file is NOT loaded for datastream-only mode.Related to
Closes: #112137
Closes: elastic/apm-server#13898