-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add support for merging custom meta data in tribe node #21552
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
Add support for merging custom meta data in tribe node #21552
Conversation
|
@bleskes can you take a look? |
874bcd4 to
a308ffa
Compare
|
Seems like this PR fixes #9372 ? |
|
FYI @areek is working on allowing custom type instances to be removed as well (which is currently not part of the PR) |
e6c20b1 to
2e41eb2
Compare
2e41eb2 to
a3a74c8
Compare
bleskes
left a comment
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 looks very good. I left some comments that I think will simplify the code.
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.
nit: can we document that the neither original customs should be changed by this method?
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.
added it to the docs
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 method became useless I think? the whole try catch can be removed as it's handled by the caller in the ClusterService. I think we should break applyUpdate into several methods each updating a different parts. i.e., updateNodes, updateIndices and now the now updateCustoms
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 for the suggestion. I decomposed applyUpdate to two methods updateNodes and updateIndicesAndMetaData instead. Currently, MetaData is updated when we update indices and when we update the customs, so it made sense to updateCustoms when we are done updating MetaData for updating indices. I think it would be messy to try to update MetaData in two separate methods from the top-level execute
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.
Why do you we need the custom of the tribe node?
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.
Apologies for the misleading comment (updated it now). This special cases getting the custom for the tribeClient that triggered the current cluster state update. Because we have the latest cluster state from the clusterChangedEvent for this tribeClient, we use that instead of looking up the state from the tribeClient's cluster service.
I think this is the right thing to do here, though I have tested it out without this special case and it still works. I am worried if the tribeClient's state from the cluster service (which initiated the cluster state update) is outdated w.r.t its latest changes. WDYT @bleskes ?
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.
nit: can we have this ugliness in a getClusterService(Node node) method? we use it in doStart 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.
done
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.
can we make this a proper getCurrentCustomsFromNodes method and test it etc?
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.
we only get a list of MergableCustomMetaDatas from this for all the tribeClient nodes and if we do the special casing as mentioned here, extracting it to a static function and testing it would be difficult. I think we are better off beefing up the integration tests TribeIT to deal with multiple customs instead?
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 added tribe integration test for merging multiple custom metadata types
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.
do we really need this extra protection? I mean the type was already in our changed type 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.
no we don't, I removed the extra protection
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 don't think you need an if else structure here? you can set the first and iterate over the rest? This can be simplified
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 simplified it as suggested
Currently, when any underlying cluster has custom metadata (via plugin), tribe node does not store custom meta data in its cluster state. This is because the tribe node has no idea how to select the appropriate custom metadata from one or many custom metadata (corresponding to the number of underlying clusters). This change adds an interface that custom metadata implementations can extend to add support for merging mulitple custom metadata of the same type for storing in the tribe state. Relates to elastic#20544 Supersedes elastic#20791
6becea3 to
b216ac5
Compare
b216ac5 to
cec9960
Compare
83ac215 to
16d6500
Compare
bleskes
left a comment
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.
Thx @areek . I left some more comments. I would be great to have a test that tests batching incoming cluster states 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.
accumulator is not currentstate?
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.
thinking about it more - do we even need this accumulator?
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 cleaned up the code and removed the redundant accumulator
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.
Answering here - I would prefer keeping the logic the same for all nodes i.e., any custom change is processed based on the latest cluster state of those nodes. No need to special case the current node as I don't see what it buys us but complexity? without it it can be a simple stream
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.
okay, I am assuming tribe node receives the cluster changed event only after the change has been applied to the underlying cluster. I removed the special casing for this and converted into a simple stream
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.
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 can be out of if now.
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.
we can make this a function to List<MergableCustomMetaData> - we alreay check with instance of in the implementation of it.
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.
if we do so, I think this becomes a simple stream reduce
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.
changed it to accept a function returning List<MergableCustomMetaData and doing so did simplify the mergeChangedCustomMetaData function to a stream reduce
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 think we need some testing with removed customs? i.e., nulls?
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.
the mergeChangedCustomMetaData never gets null values for removed customs, instead they are not supplied by the customMetaDataByTribeNode function at all when a mergable custom metadata has been removed. I added tests for removing customs in TribeIT (testMergingRemovedCustomMetaData and testMergingMultipleCustomMetaData)
7caf1a3 to
7a54c67
Compare
7a54c67 to
ae4c137
Compare
bleskes
left a comment
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. I like the last iteration a lot. Did you see my question about testing bulk processing of incoming states? Maybe I missed it.
| } | ||
| return tribeCustomMetaDataList; | ||
| } | ||
| customMetaDataType -> tribeClientNodes.stream() |
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.
👍
| MetaData.Custom mergedCustomMetaData = mergedCustomMetaDataMap.get(changedCustomMetaDataType); | ||
| if (mergedCustomMetaData == null) { | ||
| // we ignore merging custom md which doesn't implement MergableCustomMetaData interface | ||
| if (currentState.metaData().custom(changedCustomMetaDataType) instanceof MergableCustomMetaData) { |
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'm wondering if we really need this check - when is it relevant?
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.
when a non-mergable custom md changes, it is in changedCustomMetaDataTypeSet but is ignored by mergeChangedCustomMetaData (returns a null for the custom type). So we can delete non-mergable custom md from the tribe cluster, while trying to merge mergable custom md. This check prevents deleting these non-mergable custom md.
|
@bleskes I am working on writing some simple unit tests for |
|
I am going to merge this to master and backport it to 5.x branch now. Will add the unit tests (including tsting bulk processing of incoming states) for |
* Add support for merging custom meta data in tribe node Currently, when any underlying cluster has custom metadata (via plugin), tribe node does not store custom meta data in its cluster state. This is because the tribe node has no idea how to select the appropriate custom metadata from one or many custom metadata (corresponding to the number of underlying clusters). This change adds an interface that custom metadata implementations can extend to add support for merging mulitple custom metadata of the same type for storing in the tribe state. Relates to #20544 Supersedes #20791 * Simplify updating tribe state * Add tests for merging multiple custom metadata types in tribe node * cleanup merging custom md logic in tribe service
* master: (42 commits) Add support for merging custom meta data in tribe node (elastic#21552) [DOCS] Show EC2's auto attribute (elastic#21474) Add information about the removal of store throttling to the migration guide. Add a recommendation against large documents to the docs. (elastic#21652) Add indices options tests to search api REST tests (elastic#21701) Fixing indentation in geospatial querying example. (elastic#21682) Fix typo in filters aggregation docs (elastic#21690) Add BWC layer for Exceptions (elastic#21694) Add checkstyle rule to forbid empty javadoc comments (elastic#20881) Docs: Added offline install link for discovery-file plugin remove pointless catch exception in TransportSearchAction (elastic#21689) Rename ClusterState#lookupPrototypeSafe to `lookupPrototype` and remove previous "unsafe" unused variant (elastic#21686) Use a buffer to do character to byte conversion in StreamOutput#writeString (elastic#21680) Fix integer overflows when dealing with templates. (elastic#21628) Fix highlighting on a stored keyword field (elastic#21645) Set execute permissions for native plugin programs (elastic#21657) adjust visibility of DiscoveryNodes.Delta constructor Remove unused DiscoveryNodes.Delta constructor Remove unused DiscoveryNode#removeDeadMembers public method Remove minNodeVersion and corresponding public `getSmallestVersion` getter method from DiscoveryNodes ...
This commit makes TribeNodeClusterStateTaskExecutor a static class for unit testing. TribeNodeClusterStateTaskExecutor is responsible for applying cluster state updates to the tribe node state whenever an underlying cluster state is updated (i.e. adding/removing indices, updating nodes and merging custom metadata). The unit tests ensure the tribe state is properly updating when underlying cluster state tasks are seen by the tribe node in batches or as a single update. relates elastic#21552
Currently, when any underlying cluster has custom metadata
(via plugin), tribe node does not store custom meta data in its
cluster state. This is because the tribe node has no idea how to
select the appropriate custom metadata from one or many custom
metadata (corresponding to the number of underlying clusters).
This change adds an interface that custom metadata implementations
can extend to add support for merging mulitple custom metadata of
the same type for storing in the tribe state.
Relates to #20544
Supersedes #20791
Closes #9372