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

Better support for RouteBuilder for deprecate for removal vs. deprecate and keep #113712

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jakelandis
Copy link
Contributor

@jakelandis jakelandis commented Sep 27, 2024

This commit is a follow up to #113151 to better clarify how to deprecate HTTP routes. That change introduced RouteBuilder.deprecateAndKeep to enable the ability to deprecate an HTTP API, but not require REST compatibilty headers in the next major version. This commit deprecates the java methnod RouteBuilder.deprecated and introduces RouteBuilder.deprecatedForRemoval. The valid options are now RouteBuilder.deprecateAndKeep vs. RouteBuilder.deprecatedForRemoval where the later will require compatiblity headers to access the route in any newer REST API versions than the lastFullySupportedVersion declared. The javadoc should help to provide some clarification.

Additionally, the deprecation level should not be configurable. The deprecation level of WARN, when applied to routes, is informational only (and may require compatibility headers in the next version). The deprecation level of CRITICAL means means no access what so ever in the next major version. Generally, CRTICIAL is used for any cases where the compatibility is required (which means it is the last version for any access), or no compatibility is planned.

Some examples:

Route.builder(GET, "/foo/bar").build() -> no deprecations
Route.builder(GET, "/foo/bar").deprecateAndKeep("my message").build() -> deprecated, but removal is not influenced by REST API compatibilty
Route.builder(GET, "/foo/bar").deprecatedForRemoval("my message", V_8).build() -> will be available in V_8, but emit a warn level deprecation, V_9 will require compatiblity headers and emit a CRITICAL deprecation, and V_10 this will no longer be available
Route.builder(GET, "/foo/bar").replaces(GET, "/foo/baz", V_8).build() -> /foo/bar will be available in all versions. /foo/baz will be available in V_8 but emit a warn level deprecation, V_9 will require compatibility headers and emit a CRITICAL deprecation, and V_10 this will no longer be available. This is effectively a short cut to register a new route ("/foo/bar") and deprecatedForRemoval the path being replaced.

The functionality remains unchanged and this refactoring only provides better contracts and cleans up some of the implementation.

@jakelandis jakelandis changed the title Better support for RouteBuilder to deprecate removal or deprecate to keep Better support for RouteBuilder for deprecate for removal vs. deprecate and keep Sep 27, 2024
@jakelandis
Copy link
Contributor Author

@elasticmachine merge upstream

) {
// e.g. [POST /_optimize] is deprecated! Use [POST /_forcemerge] instead.
final String replacedMessage = "["
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was moved in to the builder since that is the only place we can express "replaced"

@@ -173,7 +177,7 @@ private Route(
* @param path the path, e.g. "/"
*/
public Route(Method method, String path) {
this(method, path, RestApiVersion.current(), null, null, null);
this(method, path, RestApiVersion.current(), null, Level.OFF, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we effectively ignore Level.OFF, but it more expressive than passing around null (which used to have meaning based on the other context .. here even though it is not used, it should be expressive)

@@ -77,19 +77,18 @@ public DeprecationRestHandler(
@Override
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
if (compatibleVersionWarning == false) {
// The default value for deprecated requests without a version warning is WARN
if (deprecationLevel == null || deprecationLevel == Level.WARN) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is where defaulted to null to mean WARN (and below we defaulted null to mean CRITICAL). This PR moves that be more explicit and closer to where it is declared.

@jakelandis jakelandis added >non-issue :Core/Infra/Core Core issues without another label labels Sep 30, 2024
@jakelandis jakelandis marked this pull request as ready for review September 30, 2024 23:00
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Sep 30, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@arpadkiraly arpadkiraly requested a review from a team October 3, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants