Skip to content

Conversation

@gmarouli
Copy link
Contributor

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.

@gmarouli gmarouli added :Data Management/Indices APIs APIs to create and manage indices and templates >refactoring labels Jan 29, 2025
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
Copy link
Contributor Author

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.

@gmarouli gmarouli marked this pull request as ready for review January 31, 2025 13:46
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Jan 31, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@gmarouli gmarouli added auto-backport Automatically create backport pull requests when merged v8.18.1 v8.19.0 v9.0.1 and removed Team:Data Management Meta label for data/management team labels Jan 31, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Jan 31, 2025
}));
})
PrecomputedData precomputedData = new PrecomputedData();
try (var refs = new RefCountingListener(checkAndCreateResponse(state, request, precomputedData, listener))) {
Copy link
Member

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!

Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

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

LGTM

@gmarouli gmarouli added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Feb 4, 2025
@elasticsearchmachine elasticsearchmachine merged commit 95c9b4b into elastic:main Feb 4, 2025
18 checks passed
@gmarouli gmarouli deleted the handle-9/deprecate-node-attrs-v2-follow-up branch February 4, 2025 08:48
@elasticsearchmachine
Copy link
Collaborator

elasticsearchmachine commented Feb 4, 2025

❤️ Backport succeeded

Status Branch Result
8.18
8.x
9.0

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 121181

gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Feb 4, 2025
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.
gmarouli added a commit that referenced this pull request Feb 4, 2025
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.
fzowl pushed a commit to voyage-ai/elasticsearch that referenced this pull request Feb 4, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Data Management/Indices APIs APIs to create and manage indices and templates >refactoring Team:Data Management Meta label for data/management team v8.18.1 v8.19.0 v9.0.1 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants