Skip to content
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

Deprecate performing update operation with default pipeline or final pipeline #16712

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed

### Deprecated
- Performing update operation with default pipeline or final pipeline is deprecated

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
setup:
- do:
ingest.put_pipeline:
id: "pipeline1"
body: >
{
"description": "_description",
"processors": [
{
"set" : {
"field" : "field1",
"value": "value1"
}
}
]
}
- do:
indices.create:
index: test_1
body:
settings:
index.default_pipeline: "pipeline1"
- do:
indices.create:
index: test_2
body:
settings:
index.final_pipeline: "pipeline1"
---
teardown:
- do:
ingest.delete_pipeline:
id: "pipeline1"
ignore: 404

- do:
indices.delete:
index: test_1
- do:
indices.delete:
index: test_2
---
"update operation with predefined default or final pipeline returns warning header":
- skip:
version: " - 3.0.0"
reason: "this change is added in 3.0.0"
features: allowed_warnings
- do:
index:
index: test_1
id: 1
body: { foo: bar }

- match: { _seq_no: 0 }
- match: { _version: 1 }
- match: { _primary_term: 1 }
- match: { result: created }

- do:
allowed_warnings:
- "the index [test_1] has a default ingest pipeline or a final ingest pipeline, but performing update operation with ingest pipeline causes unexpected result, this support will be removed in 3.0.0"
update:
index: test_1
id: 1
_source: true
body:
doc: { foo: bar1 }

- match: { _seq_no: 1 }
- match: { _primary_term: 1 }
- match: { _version: 2 }
- match: { result: updated }
- match: { get._source.foo: bar1 }
- match: { get._source.field1: value1 }

- do:
index:
index: test_2
id: 1
body: { foo: bar }

- match: { _seq_no: 0 }
- match: { _version: 1 }
- match: { _primary_term: 1 }
- match: { result: created }

- do:
allowed_warnings:
- "the index [test_2] has a default ingest pipeline or a final ingest pipeline, but performing update operation with ingest pipeline causes unexpected result, this support will be removed in 3.0.0"
update:
index: test_2
id: 1
_source: true
body:
doc: { foo: bar1 }

- match: { _seq_no: 1 }
- match: { _primary_term: 1 }
- match: { _version: 2 }
- match: { result: updated }
- match: { get._source.foo: bar1 }
- match: { get._source.field1: value1 }
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.bytes.BytesReference;
Expand All @@ -67,6 +69,7 @@
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.index.IndexService;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.engine.VersionConflictEngineException;
import org.opensearch.index.shard.IndexShard;
import org.opensearch.index.shard.IndexingStats.Stats.DocStatusStats;
Expand All @@ -90,7 +93,7 @@
* @opensearch.internal
*/
public class TransportUpdateAction extends TransportInstanceSingleOperationAction<UpdateRequest, UpdateResponse> {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TransportUpdateAction.class);
private final AutoCreateIndex autoCreateIndex;
private final UpdateHelper updateHelper;
private final IndicesService indicesService;
Expand Down Expand Up @@ -276,6 +279,15 @@
IndexRequest indexRequest = result.action();
// we fetch it from the index request so we don't generate the bytes twice, its already done in the index request
final BytesReference indexSourceBytes = indexRequest.source();
final Settings indexSettings = indexService.getIndexSettings().getSettings();

Check warning on line 282 in server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java#L282

Added line #L282 was not covered by tests
if (IndexSettings.DEFAULT_PIPELINE.exists(indexSettings) || IndexSettings.FINAL_PIPELINE.exists(indexSettings)) {
deprecationLogger.deprecate(

Check warning on line 284 in server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java#L284

Added line #L284 was not covered by tests
"update_operation_with_ingest_pipeline",
"the index ["
+ indexRequest.index()

Check warning on line 287 in server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java#L287

Added line #L287 was not covered by tests
+ "] has a default ingest pipeline or a final ingest pipeline, but performing update operation with ingest pipeline causes unexpected result, this support will be removed in 3.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the message is bit confusing, may be something along these lines:

 "the index ["+ indexRequest.index() + "] has a default ingest pipeline or a final ingest pipeline, the support of the ingest pipelines for update operation causes unexpected result and will be removed in 3.0.0"

My take on this is that the default / final ingest pipelines are agnostic to the fact that update request is treated as index request, so user cannot do anything about it, right? (removing these pipelines is not an option since those could be used for ingestion of new documents).

The doubt for me here is the deprecation warning vs warning in logs (or may be both). Could user optout from this behavior now? (apply pipeline for index request, skip for update requests?)

);
}
client.bulk(toSingleItemBulkRequest(indexRequest), wrapBulkResponse(ActionListener.<IndexResponse>wrap(response -> {
UpdateResponse update = new UpdateResponse(
response.getShardInfo(),
Expand Down
Loading