-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Make Persistent Tasks implementations version and feature aware #31045
Conversation
This commit introduces the ability for a client to communicate to the server features that it can support and for these features to be used in influencing the decisions that the server makes when communicating with the client. To this end we carry the features from the client to the underlying stream as we carry the version of the client today. This enables us to enhance the logic where we make protocol decisions on the basis of the version on the stream to also make protocol decisions on the basis of the features on the stream. With such functionality, the client can communicate to the server if it is a transport client, or if it has, for example, X-Pack installed. This enables us to support rolling upgrades from the OSS distribution to the default distribution without breaking client connectivity as we can now elect to serialize customs in the cluster state depending on whether or not the client reports to us using the feature capabilities that it can under these customs. This means that we would avoid sending a client pieces of the cluster state that it can not understand. However, we want to take care and always send the full cluster state during node-to-node communication as otherwise we would end up with different understanding of what is in the cluster state across nodes depending on which features they reported to have. This is why when deciding whether or not to write out a custom we always send the custom if the client is not a transport client and otherwise do not send the custom if the client is transport client that does not report to have the feature required by the custom. Co-authored-by: Yannick Welsch <yannick@welsch.lu>
Pinging @elastic/es-distributed |
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.
Overall it looks good. I left some suggestions and one required change.
@@ -19,17 +19,10 @@ | |||
|
|||
package org.elasticsearch.cluster; | |||
|
|||
import org.elasticsearch.Version; | |||
import org.elasticsearch.common.io.stream.NamedWriteable; | |||
import org.elasticsearch.common.io.stream.VersionedNamedWriteable; | |||
|
|||
/** | |||
* Diff that also support NamedWriteable interface |
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.
This could should be modified to VersionedNamedWriteable
now.
@@ -382,6 +383,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { | |||
return Version.V_5_0_0; |
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.
It is unfortunate that this has to be littered everywhere and anyway it will become a lie when we remove the 5.x constants from the codebase on some future cleanup. Why not use Version#minimumCompatibilityVersion
as a default implementation on the interface?
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 felt that people should really think about these things and not just rely on defaults. Another aspect is that this change currently means it is littered everywhere in this PR but when people introduce a new VersionedNamedWritable
the have to set something can't use a default. When 5.x is phased out we can replace it with Version#minimumCompatibilityVersion
(I can do so now if you want) but I think it should be done on a case by case basis. Defaults are dangerous here imo.
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.
Fair enough. Let's go with Version#minimumCompatibilityVersion
everywhere now though.
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.
Sure.
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 replaced all occurrences of V5_0_0. Let me know if you want the other 5.x replaced as well.
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.
Yeah, let's get those here too.
randomAssignment()); | ||
final BytesStreamOutput out = new BytesStreamOutput(); | ||
out.setVersion(streamVersion); | ||
Set<String> features = new HashSet<>(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
new PersistentTasksCustomMetaData(new NamedWriteableAwareStreamInput(input, getNamedWriteableRegistry())); | ||
|
||
Set<String> expectedIds = new HashSet<>(tasks.getCurrentTaskIds()); | ||
expectedIds.remove("test_incompatible_version"); |
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.
This is indirect. Why not Collections.singleton("test_compatible_version")
? Then the local is not even needed and it saves a few lines too.
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.
Left over where I had more random tasks in there but I removed it due to other issues. Will simplify.
PersistentTasksCustomMetaData read = new PersistentTasksCustomMetaData( | ||
new NamedWriteableAwareStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry())); | ||
Set<String> expectedIds = new HashSet<>(tasks.getCurrentTaskIds()); | ||
expectedIds.remove("test_incompatible"); |
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.
Same comment on the indirectness.
@@ -97,6 +95,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { |
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.
See my comment about littering.
@@ -103,6 +104,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { |
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.
See my comment about littering.
@@ -69,6 +70,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { |
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.
See my comment about littering.
@@ -383,6 +383,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { |
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.
See my comment about littering.
@@ -108,6 +108,11 @@ public String getWriteableName() { | |||
return TYPE; | |||
} | |||
|
|||
@Override | |||
public Version getMinimalSupportedVersion() { |
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.
Don't mess with Texas.
Thanks @jasontedor . I responded to all your comments. Can you take another look? |
@@ -299,8 +299,7 @@ public void testFeatureSerialization() throws IOException { | |||
|
|||
PersistentTasksCustomMetaData read = new PersistentTasksCustomMetaData( | |||
new NamedWriteableAwareStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry())); | |||
Set<String> expectedIds = new HashSet<>(tasks.getCurrentTaskIds()); | |||
expectedIds.remove("test_incompatible"); | |||
Set<String> expectedIds = Collections.singleton("test_compatible"); |
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.
Inline this directly to the assertion?
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.
sure
tasks.build().writeTo(out); | ||
|
||
final StreamInput input = out.bytes().streamInput(); | ||
input.setVersion(streamVersion); | ||
PersistentTasksCustomMetaData read = | ||
new PersistentTasksCustomMetaData(new NamedWriteableAwareStreamInput(input, getNamedWriteableRegistry())); | ||
|
||
Set<String> expectedIds = new HashSet<>(tasks.getCurrentTaskIds()); | ||
expectedIds.remove("test_incompatible_version"); | ||
Set<String> expectedIds = Collections.singleton("test_compatible_version"); |
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.
Inline this directly to the assertion?
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.
sure
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.
LGTM assuming CI is happy and you address the remaining 5.x versions that are less than the current minimum compatibility version.
Thanks @jasontedor . I'll start the song and dance of backporting. |
Thanks @bleskes. |
With #31020 we introduced the ability for transport clients to indicate what features they support in order to make sure we don't serialize object to them they don't support. This PR adapts the serialization logic of persistent tasks to be aware of those features and not serialize tasks that aren't supported. Also, a version check is added for the future where we may add new tasks implementations and need to be able to indicate they shouldn't be serialized both to nodes and clients. As the implementation relies on the interface of `PersistentTaskParams`, these are no longer optional. That's acceptable as all current implementation have them and we plan to make `PersistentTaskParams` more central in the future. Relates to #30731
With #31020 we introduced the ability for transport clients to indicate what features they support in order to make sure we don't serialize object to them they don't support. This PR adapts the serialization logic of persistent tasks to be aware of those features and not serialize tasks that aren't supported. Also, a version check is added for the future where we may add new tasks implementations and need to be able to indicate they shouldn't be serialized both to nodes and clients. As the implementation relies on the interface of `PersistentTaskParams`, these are no longer optional. That's acceptable as all current implementation have them and we plan to make `PersistentTaskParams` more central in the future. Relates to #30731
* master: Remove usage of explicit type in docs (elastic#29667) Share common readFrom/writeTo code in AcknowledgeResponse (elastic#30983) Adapt bwc versions after backporting elastic#31045 to 6.x Mute MatchPhrase*QueryBuilderTests [Docs] Fix typo in watcher conditions documentation (elastic#30989) Remove wrong link in index phrases doc Move pipeline APIs to ingest namespace (elastic#31027) [DOCS] Fixes accounting setting names (elastic#30863) [DOCS] Rewords _field_names documentation (elastic#31029) Index phrases (elastic#30450)
This is now backported all the way to 6.3 |
* master: Match phrase queries against non-indexed fields should throw an exception (#31060) In the internal highlighter APIs, use the field type as opposed to the mapper. (#31039) [DOCS] Removes duplicated authentication pages Enable customizing REST tests blacklist (#31074) Make sure KeywordFieldMapper#clone preserves split_queries_on_whitespace. (#31049) [DOCS] Moves machine learning overview to stack-docs [ML] Add secondary sort to ML events (#31063) [Rollup] Specialize validation exception for easier management (#30339) Adapt bwc versions after backporting #31045 to 6.3 Remove usage of explicit type in docs (#29667) Share common readFrom/writeTo code in AcknowledgeResponse (#30983) Adapt bwc versions after backporting #31045 to 6.x Mute MatchPhrase*QueryBuilderTests [Docs] Fix typo in watcher conditions documentation (#30989) Remove wrong link in index phrases doc Move pipeline APIs to ingest namespace (#31027) [DOCS] Fixes accounting setting names (#30863) [DOCS] Rewords _field_names documentation (#31029) Index phrases (#30450) Remove leftover debugging from PTCMDT Fix PTCMDT#testMinVersionSerialization Make Persistent Tasks implementations version and feature aware (#31045)
* 6.x: Add TRACE, CONNECT, and PATCH http methods (#31079) Change ObjectParser exception (#31030) Make sure KeywordFieldMapper#clone preserves split_queries_on_whitespace. (#31049) [DOCS] Removes duplicated authentication pages [Rollup] Specialize validation exception for easier management (#30339) Enable customizing REST tests blacklist (#31074) [DOCS] Moves machine learning overview to stack-docs [ML] Add secondary sort to ML events (#31063) QA: Check rollup job creation safety (#31036) Adapt bwc versions after backporting #31045 to 6.3 Remove usage of explicit type in docs (#29667) Move pipeline APIs to ingest namespace (#31027) Adapt bwc versions after backporting #31045 to 6.x Make Persistent Tasks implementations version and feature aware (#31045) Mute MatchPhrase*QueryBuilderTests [Docs] Fix typo in watcher conditions documentation (#30989) Remove wrong link in index phrases doc Reuse expiration date of trial licenses (#31033) Index phrases (#30450) [DOCS] Fixes accounting setting names (#30863) [DOCS] Rewords _field_names documentation (#31029)
With #31020 we introduced the ability for transport clients to indicate what features they support in order to make sure we don't serialize object to them they don't support. This PR adapts the serialization logic of persistent tasks to be aware of those features and not serialize tasks that aren't supported.
Also, a version check is added for the future where we may add new tasks implementations and need to be able to indicate they shouldn't be serialized both to nodes and clients.
As the implementation relies on the interface of
PersistentTaskParams
, these are no longer optional. That's acceptable as all current implementation have them and we plan to makePersistentTaskParams
more central in the future.Relates to #30731