-
Notifications
You must be signed in to change notification settings - Fork 25.6k
DeprecationInfoAction refactoring
#121181
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
DeprecationInfoAction refactoring
#121181
Conversation
| var templateIssues = (List<?>) issuesByTemplate.get(templateName); | ||
| assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); | ||
| } else { | ||
| // Bwc version with 8.18 until https://github.com/elastic/elasticsearch/pull/120505/ gets backported, clean up after backport |
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.
Removed because the backport has been completed.
|
Pinging @elastic/es-data-management (Team:Data Management) |
| })); | ||
| }) | ||
| PrecomputedData precomputedData = new PrecomputedData(); | ||
| try (var refs = new RefCountingListener(checkAndCreateResponse(state, request, precomputedData, listener))) { |
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 had no idea this existed. Good to know!
masseyke
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
❤️ Backport succeeded
You can use sqren/backport to manually backport by running |
This refactoring was motivated by the following issues with the current state of the code: - The `TransformDeprecationChecker` is listed as plugin checker, but later we remove is from the `plugin_settings` and add it to the `cluster_settings`. This made me consider that the checker might be dealing with transform deprecation warnings but if they are listed under the `cliuster_settings`, it fits better to be part of `ClusterDeprecationChecker`. - The `DeprecationInfo` is a data class, but it has a method `from` which constructs an `DeprecationInfo.Response` instance. However, this is not a simple factory class but it actually runs all the checks and it also tries to assert that it is not executed on a transport thread. Considering this, I thought it might fit better to the `TransportDeprecationInfoAction`, this way all the logic is in one place and all the checkers are wired and used in the same class. - Constructing the node settings deprecation issues requires to merge the deprecation warnings of the individual nodes. We considered bringing together the execution of the remote request and the construction of the response in a new class called `NodeDeprecationChecker` that resembles the patterns of the other Checker classes. - Reinstated the `PLUGIN_CHECKERS` even if we have only one check, so other developers can easier add their plugin checks. - Finally, we noticed that the way we synthesise the remote requests is difficult to read and maintain because each call is nested under the previous one. We propose in this PR a different pattern that uses the `RefCountingListener` to combine the different remote calls and store their results in a container class named `PrecomputedData` - **Bonus**: Removed the `LegacyIndexTemplateDeprecationChecker.java` which was not used.
This refactoring was motivated by the following issues with the current state of the code: - The `TransformDeprecationChecker` is listed as plugin checker, but later we remove is from the `plugin_settings` and add it to the `cluster_settings`. This made me consider that the checker might be dealing with transform deprecation warnings but if they are listed under the `cliuster_settings`, it fits better to be part of `ClusterDeprecationChecker`. - The `DeprecationInfo` is a data class, but it has a method `from` which constructs an `DeprecationInfo.Response` instance. However, this is not a simple factory class but it actually runs all the checks and it also tries to assert that it is not executed on a transport thread. Considering this, I thought it might fit better to the `TransportDeprecationInfoAction`, this way all the logic is in one place and all the checkers are wired and used in the same class. - Constructing the node settings deprecation issues requires to merge the deprecation warnings of the individual nodes. We considered bringing together the execution of the remote request and the construction of the response in a new class called `NodeDeprecationChecker` that resembles the patterns of the other Checker classes. - Reinstated the `PLUGIN_CHECKERS` even if we have only one check, so other developers can easier add their plugin checks. - Finally, we noticed that the way we synthesise the remote requests is difficult to read and maintain because each call is nested under the previous one. We propose in this PR a different pattern that uses the `RefCountingListener` to combine the different remote calls and store their results in a container class named `PrecomputedData` - **Bonus**: Removed the `LegacyIndexTemplateDeprecationChecker.java` which was not used.
This refactoring was motivated by the following issues with the current state of the code: - The `TransformDeprecationChecker` is listed as plugin checker, but later we remove is from the `plugin_settings` and add it to the `cluster_settings`. This made me consider that the checker might be dealing with transform deprecation warnings but if they are listed under the `cliuster_settings`, it fits better to be part of `ClusterDeprecationChecker`. - The `DeprecationInfo` is a data class, but it has a method `from` which constructs an `DeprecationInfo.Response` instance. However, this is not a simple factory class but it actually runs all the checks and it also tries to assert that it is not executed on a transport thread. Considering this, I thought it might fit better to the `TransportDeprecationInfoAction`, this way all the logic is in one place and all the checkers are wired and used in the same class. - Constructing the node settings deprecation issues requires to merge the deprecation warnings of the individual nodes. We considered bringing together the execution of the remote request and the construction of the response in a new class called `NodeDeprecationChecker` that resembles the patterns of the other Checker classes. - Reinstated the `PLUGIN_CHECKERS` even if we have only one check, so other developers can easier add their plugin checks. - Finally, we noticed that the way we synthesise the remote requests is difficult to read and maintain because each call is nested under the previous one. We propose in this PR a different pattern that uses the `RefCountingListener` to combine the different remote calls and store their results in a container class named `PrecomputedData` - **Bonus**: Removed the `LegacyIndexTemplateDeprecationChecker.java` which was not used.
This refactoring was motivated by the following issues with the current state of the code:
TransformDeprecationCheckeris listed as plugin checker, but later we remove is from theplugin_settingsand add it to thecluster_settings. This made me consider that the checker might be dealing with transform deprecation warnings but if they are listed under thecliuster_settings, it fits better to be part ofClusterDeprecationChecker.DeprecationInfois a data class, but it has a methodfromwhich constructs anDeprecationInfo.Responseinstance. However, this is not a simple factory class but it actually runs all the checks and it also tries to assert that it is not executed on a transport thread. Considering this, I thought it might fit better to theTransportDeprecationInfoAction, this way all the logic is in one place and all the checkers are wired and used in the same class.NodeDeprecationCheckerthat resembles the patterns of the other Checker classes.PLUGIN_CHECKERSeven if we have only one check, so other developers can easier add their plugin checks.RefCountingListenerto combine the different remote calls and store their results in a container class namedPrecomputedDataLegacyIndexTemplateDeprecationChecker.javawhich was not used.