-
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
Continue registering pipelines after one pipeline parse failure. #28752
Changes from 6 commits
bcfa96d
a1336c4
1680c0f
0d3caba
e25ea29
2da875c
4d2d3ee
dfb2679
02d3f97
31a22aa
534e155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,16 +81,22 @@ void innerUpdatePipelines(ClusterState previousState, ClusterState state) { | |
} | ||
|
||
Map<String, Pipeline> pipelines = new HashMap<>(); | ||
ArrayList<ElasticsearchParseException> exceptions = new ArrayList<>(); | ||
for (PipelineConfiguration pipeline : ingestMetadata.getPipelines().values()) { | ||
try { | ||
pipelines.put(pipeline.getId(), factory.create(pipeline.getId(), pipeline.getConfigAsMap(), processorFactories)); | ||
} catch (ElasticsearchParseException e) { | ||
throw e; | ||
pipelines.put(pipeline.getId(), new Pipeline("invalid_" + pipeline.getId(), e.getMessage(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if we create a pipeline that throws the exception for us (fail processor is in a ingest-common, but it very simple to have that behaviour here too): pipelines.put(pipeline.getId(), substitutePipeline(pipeline.getId(), e));
private Pipeline substitutePipeline(String id, ElasticsearchParseException e) {
String tag = e.getHeaderKeys().contains("processor_tag") ? e.getHeader("processor_tag").get(0) : null;
String type = e.getHeaderKeys().contains("processor_type") ? e.getHeader("processor_type").get(0) : "unknown";
String errorMessage = "pipeline with id [" + id + "] could not be loaded, caused by [" + e.getDetailedMessage() + "]";
Processor failureProcessor = new AbstractProcessor(tag) {
@Override
public void execute(IngestDocument ingestDocument) throws Exception {
throw new IllegalStateException(errorMessage);
}
@Override
public String getType() {
return type;
}
};
String description = "this is a place holder pipeline, because pipeline with id [" + id + "] could not be loaded";
return new Pipeline(id, description, null, new CompoundProcessor(failureProcessor));
} This way the if statement added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, I updated the above comment. Also I think it is important to throw an IllegalStateException instead of a IllegalArgumentException, because the fact that we failed to load the pipeline at this stage is a real issue and this is the best way we can deal with it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with this approach is that we will be put these substituted pipelines in PUT requests. this will return true: https://github.com/elastic/elasticsearch/pull/28752/files#diff-fd6036d9f6ce14fecb8751a3adb9fc59R280 ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm. nevermind.. for some reason I saw that test fail. I might have done something wrong or a different test failed |
||
null, new CompoundProcessor())); | ||
exceptions.add(e); | ||
} catch (Exception e) { | ||
throw new ElasticsearchParseException("Error updating pipeline with id [" + pipeline.getId() + "]", e); | ||
pipelines.put(pipeline.getId(), new Pipeline("invalid_" + pipeline.getId(), e.getMessage(), | ||
null, new CompoundProcessor())); | ||
exceptions.add(new ElasticsearchParseException("Error updating pipeline with id [" + pipeline.getId() + "]", e)); | ||
} | ||
} | ||
this.pipelines = Collections.unmodifiableMap(pipelines); | ||
ExceptionsHelper.rethrowAndSuppress(exceptions); | ||
} | ||
|
||
/** | ||
|
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.
s/ArrayList/List ?
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