Disable deprecation log indexing until templates are loaded#80406
Disable deprecation log indexing until templates are loaded#80406pgomulka merged 14 commits intoelastic:masterfrom
Conversation
Deprecation log indexing relies on index templates to be present in cluster state in order to create a data stream. If a very early deprecation is emitted after node is started up and templates are not loaded yet this can result in regular index with default settings and mappings to be created. To prevent this a bulk processor used for indexing deprecation logs delays flushing. closes elastic#80265
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
Pinging @elastic/es-data-management (Team:Data Management) |
| apply plugin: 'elasticsearch.build' | ||
| tasks.named("test").configure { enabled = false } | ||
|
|
||
| dependencies { |
There was a problem hiding this comment.
@mark-vieira would you be able to review this PR from gradle point of view?
I wasn't too sure if I should use api or implementation for dependency? do we have a readme for this?
also do I have to copy license files here as well?
There was a problem hiding this comment.
Licenses are only required once, you don't need them every time you use a dependency. We favor implementation as those dependencies are not transitively inherited by the compile classpath of consuming projects. Since this is a QA project it's mostly irrelevant (there are no consumers) but I'd still leave it all implementation here.
There was a problem hiding this comment.
if I remove the licence folder I get
Execution failed for task ':x-pack:plugin:deprecation:qa:common:dependencyLicenses'.
> Licences dir /Users/przemek/workspace/pgomulka/elasticsearch/x-pack/plugin/deprecation/qa/common/licenses does not exist, but there are dependencies: jackson-annotations-2.10.4.jar
jackson-databind-2.10.4.jar
I wonder if I miss any plugin or import?
There was a problem hiding this comment.
You shouldn't be adding the elasticsearch.build plugin to QA projects. That's specifically for production code. What is this "common" project for anyhow? I don't see any actual code belonging to it?
There was a problem hiding this comment.
What is this "common" project for anyhow?
it has only one class DeprecationTestUtils - I felt that copying that code would be a smell.
The problem boils down to the fact that EarlyDeprecationIndexingIT has to be first running against a fresh test cluster - and hence it was easiest to move it to its own project
I removed the elasticsearch.build but I had to add elasticsearch.java otherwise gradle would complain about implementation
Could not find method implementation() for arguments
There was a problem hiding this comment.
Yep, elasticsearch.java is the correct choice here.
| @@ -0,0 +1,41 @@ | |||
| import org.elasticsearch.gradle.util.GradleUtils | |||
There was a problem hiding this comment.
this is basically a copy of x-pack/plugin/deprecation/qa/rest/build.gradle
can I move shared bits to common module?
There was a problem hiding this comment.
I had to create that module, so that I could make sure that EarlyDeprecationIndexingIT is the test that runs first thing after test cluster starts
martijnvg
left a comment
There was a problem hiding this comment.
Left 2 questions. Other than that this looks good to me.
.../src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java
Outdated
Show resolved
Hide resolved
| private String globalIndex; | ||
| private String globalRouting; | ||
| private String globalPipeline; | ||
| private Supplier<Boolean> flushCondition = () -> true; |
|
|
||
| package org.elasticsearch.xpack.deprecation; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; |
There was a problem hiding this comment.
Why is databind being used here? I believe in mast of the rest integration test we use XContentMapValues, could that be used here as well?
There was a problem hiding this comment.
good idea, XContentMapValues will make it much cleaner
|
@elasticmachine run elasticsearch-ci/bwc |
|
@elasticmachine update branch |
|
|
||
| @Override | ||
| public void clusterChanged(ClusterChangedEvent event) { | ||
| if (flushEnabled.get() == false) { |
There was a problem hiding this comment.
Maybe instead of wrapping multiple if statements, maybe do this:
if (flushEnabled.get()) {
return;
}
if (event.metadataChanged() == false) {
return;
}
// rest of the codeI think this is more readable.
…/elasticsearch into main/bulk_processor_flush_delay
| Response response = getIndexSettings(); | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
|
|
||
| final JsonNode jsonNode = mapper.readTree(response.getEntity().getContent()); |
There was a problem hiding this comment.
I think we can remove the JsonNode usage here as well? And use XContentMapValues ?
…80406) Deprecation log indexing relies on index templates to be present in cluster state in order to create a data stream. If a very early deprecation is emitted after node is started up and templates are not loaded yet this can result in regular index with default settings and mappings to be created. To prevent this a bulk processor used for indexing deprecation logs delays flushing until templates are loaded. closes elastic#80265
…80406) Deprecation log indexing relies on index templates to be present in cluster state in order to create a data stream. If a very early deprecation is emitted after node is started up and templates are not loaded yet this can result in regular index with default settings and mappings to be created. To prevent this a bulk processor used for indexing deprecation logs delays flushing until templates are loaded. closes elastic#80265
…80406) (#80529) Deprecation log indexing relies on index templates to be present in cluster state in order to create a data stream. If a very early deprecation is emitted after node is started up and templates are not loaded yet this can result in regular index with default settings and mappings to be created. To prevent this a bulk processor used for indexing deprecation logs delays flushing until templates are loaded. closes #80265 backports #80406
…ckport(#80406) (#80345) Deprecation log indexing relies on index templates to be present in cluster state in order to create a data stream. If a very early deprecation is emitted after node is started up and templates are not loaded yet this can result in regular index with default settings and mappings to be created. To prevent this a bulk processor used for indexing deprecation logs delays flushing until templates are loaded. closes #80265 backport #80406
Deprecation log indexing relies on index templates to be present in
cluster state in order to create a data stream.
If a very early deprecation is emitted after node is started up and
templates are not loaded yet this can result in regular index with
default settings and mappings to be created.
To prevent this a bulk processor used for indexing deprecation logs
delays flushing until templates are loaded.
closes #80265