X-Pack: Remove deprecated handlers, remove watcher restart action (elastic/x-pack-elasticsearch#2133)

The deprecated handlers should have been removed earlier, but are now
going to to away finally.

Also the watcher restart action has been removed, mainly because users
should not blindly restart, but always make sure, that watcher is
stopped correctly before restarting. This had been removed from the
transport action previously.

Original commit: elastic/x-pack-elasticsearch@78a5ec3c05
This commit is contained in:
Alexander Reelsen 2017-08-01 14:14:51 +02:00 committed by GitHub
parent 681ce6e2aa
commit 547b0ebc1b
24 changed files with 28 additions and 257 deletions

View File

@ -24,4 +24,3 @@ include::watcher/deactivate-watch.asciidoc[]
include::watcher/stats.asciidoc[]
include::watcher/stop.asciidoc[]
include::watcher/start.asciidoc[]
include::watcher/restart.asciidoc[]

View File

@ -1,22 +0,0 @@
[role="xpack"]
[[watcher-api-restart]]
=== Restart API
The `restart` API stops, then starts the {watcher} service, as in the
following example:
[source,js]
--------------------------------------------------
POST _xpack/watcher/_restart
--------------------------------------------------
// CONSOLE
{watcher} returns the following response if the request is successful:
[source,js]
--------------------------------------------------
{
"acknowledged": true
}
--------------------------------------------------
// TESTRESPONSE

View File

@ -19,15 +19,7 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE;
public class RestDeleteLicenseAction extends XPackRestHandler {
public RestDeleteLicenseAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(DELETE, URI_BASE + "/license", this,
DELETE, "/_license", deprecationLogger);
// Remove _licenses support entirely in 6.0
controller.registerAsDeprecatedHandler(DELETE, "/_licenses", this,
"[DELETE /_licenses] is deprecated! Use " +
"[DELETE /_xpack/license] instead.",
deprecationLogger);
controller.registerHandler(DELETE, URI_BASE + "/license", this);
}
@Override

View File

@ -30,15 +30,7 @@ public class RestGetLicenseAction extends XPackRestHandler {
@Inject
public RestGetLicenseAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(GET, URI_BASE + "/license", this,
GET, "/_license", deprecationLogger);
// Remove _licenses support entirely in 6.0
controller.registerAsDeprecatedHandler(GET, "/_licenses", this,
"[GET /_licenses] is deprecated! Use " +
"[GET /_xpack/license] instead.",
deprecationLogger);
controller.registerHandler(GET, URI_BASE + "/license", this);
}
@Override

View File

@ -23,23 +23,11 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestPutLicenseAction extends XPackRestHandler {
public RestPutLicenseAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/license", this,
POST, "/_license", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/license", this,
PUT, "/_license", deprecationLogger);
// Remove _licenses support entirely in 6.0
controller.registerAsDeprecatedHandler(POST, "/_licenses", this,
"[POST /_licenses] is deprecated! Use " +
"[POST /_xpack/license] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(PUT, "/_licenses", this,
"[PUT /_licenses] is deprecated! Use " +
"[PUT /_xpack/license] instead.",
deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/license", this);
controller.registerHandler(PUT, URI_BASE + "/license", this);
}
@Override

View File

@ -35,12 +35,6 @@ public class RestAuthenticateAction extends SecurityBaseRestHandler {
super(settings, licenseState);
this.securityContext = securityContext;
controller.registerHandler(GET, "/_xpack/security/_authenticate", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/authenticate", this,
"[GET /_shield/authenticate] is deprecated! Use " +
"[GET /_xpack/security/_authenticate] instead.",
deprecationLogger);
}
@Override

View File

@ -24,16 +24,6 @@ public final class RestClearRealmCacheAction extends SecurityBaseRestHandler {
public RestClearRealmCacheAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_clear_cache", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/realm/{realms}/_cache/clear", this,
"[POST /_shield/realm/{realms}/_cache/clear] is deprecated! Use " +
"[POST /_xpack/security/realm/{realms}/_clear_cache] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(POST, "/_shield/realm/{realms}/_clear_cache", this,
"[POST /_shield/realm/{realms}/_clear_cache] is deprecated! Use " +
"[POST /_xpack/security/realm/{realms}/_clear_cache] instead.",
deprecationLogger);
}
@Override

View File

@ -24,12 +24,6 @@ public final class RestClearRolesCacheAction extends SecurityBaseRestHandler {
public RestClearRolesCacheAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/role/{name}/_clear_cache", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/role/{name}/_clear_cache", this,
"[POST /_shield/role/{name}/_clear_cache] is deprecated! Use " +
"[POST /_xpack/security/role/{name}/_clear_cache] instead.",
deprecationLogger);
}
@Override

View File

@ -31,12 +31,6 @@ public class RestDeleteRoleAction extends SecurityBaseRestHandler {
public RestDeleteRoleAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/role/{name}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(DELETE, "/_shield/role/{name}", this,
"[DELETE /_shield/role/{name}] is deprecated! Use " +
"[DELETE /_xpack/security/role/{name}] instead.",
deprecationLogger);
}
@Override

View File

@ -33,16 +33,6 @@ public class RestGetRolesAction extends SecurityBaseRestHandler {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/role/", this);
controller.registerHandler(GET, "/_xpack/security/role/{name}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/role", this,
"[GET /_shield/role] is deprecated! Use " +
"[GET /_xpack/security/role] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(GET, "/_shield/role/{name}", this,
"[GET /_shield/role/{name}] is deprecated! Use " +
"[GET /_xpack/security/role/{name}] instead.",
deprecationLogger);
}
@Override

View File

@ -34,16 +34,6 @@ public class RestPutRoleAction extends SecurityBaseRestHandler {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/role/{name}", this);
controller.registerHandler(PUT, "/_xpack/security/role/{name}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/role/{name}", this,
"[POST /_shield/role/{name}] is deprecated! Use " +
"[POST /_xpack/security/role/{name}] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(PUT, "/_shield/role/{name}", this,
"[PUT /_shield/role/{name}] is deprecated! Use " +
"[PUT /_xpack/security/role/{name}] instead.",
deprecationLogger);
}
@Override

View File

@ -31,12 +31,6 @@ public class RestDeleteUserAction extends SecurityBaseRestHandler {
public RestDeleteUserAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/user/{username}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(DELETE, "/_shield/user/{username}", this,
"[DELETE /_shield/user/{username}] is deprecated! Use " +
"[DELETE /_xpack/security/user/{username}] instead.",
deprecationLogger);
}
@Override

View File

@ -34,16 +34,6 @@ public class RestGetUsersAction extends SecurityBaseRestHandler {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/user/", this);
controller.registerHandler(GET, "/_xpack/security/user/{username}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/user", this,
"[GET /_shield/user] is deprecated! Use " +
"[GET /_xpack/security/user] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(GET, "/_shield/user/{username}", this,
"[GET /_shield/user/{username}] is deprecated! Use " +
"[GET /_xpack/security/user/{username}] instead.",
deprecationLogger);
}
@Override

View File

@ -38,16 +38,6 @@ public class RestPutUserAction extends SecurityBaseRestHandler implements RestRe
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/user/{username}", this);
controller.registerHandler(PUT, "/_xpack/security/user/{username}", this);
// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/user/{username}", this,
"[POST /_shield/user/{username}] is deprecated! Use " +
"[POST /_xpack/security/user/{username}] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(PUT, "/_shield/user/{username}", this,
"[PUT /_shield/user/{username}] is deprecated! Use " +
"[PUT /_xpack/security/user/{username}] instead.",
deprecationLogger);
}
@Override

View File

@ -31,26 +31,10 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestAckWatchAction extends WatcherRestHandler {
public RestAckWatchAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_ack", this,
POST, "/_watcher/watch/{id}/_ack", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_ack", this,
PUT, "/_watcher/watch/{id}/_ack", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this,
POST, "/_watcher/watch/{id}/_ack/{actions}", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", this,
PUT, "/_watcher/watch/{id}/_ack/{actions}", deprecationLogger);
// @deprecated The following can be totally dropped in 6.0
// Note: we deprecated "/{actions}/_ack" totally; so we don't replace it with a matching _xpack variant
controller.registerAsDeprecatedHandler(POST, "/_watcher/watch/{id}/{actions}/_ack", this,
"[POST /_watcher/watch/{id}/{actions}/_ack] is deprecated! Use " +
"[POST /_xpack/watcher/watch/{id}/_ack/{actions}] instead.",
deprecationLogger);
controller.registerAsDeprecatedHandler(PUT, "/_watcher/watch/{id}/{actions}/_ack", this,
"[PUT /_watcher/watch/{id}/{actions}/_ack] is deprecated! Use " +
"[PUT /_xpack/watcher/watch/{id}/_ack/{actions}] instead.",
deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack", this);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack", this);
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", this);
}
@Override

View File

@ -31,18 +31,11 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestActivateWatchAction extends WatcherRestHandler {
public RestActivateWatchAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_activate", this);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_activate", this);
final DeactivateRestHandler deactivateRestHandler = new DeactivateRestHandler(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_activate", this,
POST, "/_watcher/watch/{id}/_activate", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_activate", this,
PUT, "/_watcher/watch/{id}/_activate", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler,
POST, "/_watcher/watch/{id}/_deactivate", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler,
PUT, "/_watcher/watch/{id}/_deactivate", deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler);
}
@Override

View File

@ -27,9 +27,7 @@ import static org.elasticsearch.rest.RestStatus.OK;
public class RestDeleteWatchAction extends WatcherRestHandler {
public RestDeleteWatchAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(DELETE, URI_BASE + "/watch/{id}", this,
DELETE, "/_watcher/watch/{id}", deprecationLogger);
controller.registerHandler(DELETE, URI_BASE + "/watch/{id}", this);
}
@Override

View File

@ -40,16 +40,10 @@ public class RestExecuteWatchAction extends WatcherRestHandler implements RestRe
public RestExecuteWatchAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_execute", this,
POST, "/_watcher/watch/{id}/_execute", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_execute", this,
PUT, "/_watcher/watch/{id}/_execute", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/_execute", this,
POST, "/_watcher/watch/_execute", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/_execute", this,
PUT, "/_watcher/watch/_execute", deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_execute", this);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_execute", this);
controller.registerHandler(POST, URI_BASE + "/watch/_execute", this);
controller.registerHandler(PUT, URI_BASE + "/watch/_execute", this);
}
@Override

View File

@ -28,10 +28,7 @@ import static org.elasticsearch.rest.RestStatus.OK;
public class RestGetWatchAction extends WatcherRestHandler {
public RestGetWatchAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(GET, URI_BASE + "/watch/{id}", this,
GET, "/_watcher/watch/{id}", deprecationLogger);
controller.registerHandler(GET, URI_BASE + "/watch/{id}", this);
}
@Override

View File

@ -33,12 +33,8 @@ public class RestPutWatchAction extends WatcherRestHandler implements RestReques
public RestPutWatchAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}", this,
POST, "/_watcher/watch/{id}", deprecationLogger);
controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}", this,
PUT, "/_watcher/watch/{id}", deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/watch/{id}", this);
controller.registerHandler(PUT, URI_BASE + "/watch/{id}", this);
}
@Override

View File

@ -5,9 +5,7 @@
*/
package org.elasticsearch.xpack.watcher.rest.action;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.AcknowledgedRestListener;
@ -18,62 +16,25 @@ import org.elasticsearch.xpack.watcher.transport.actions.service.WatcherServiceR
import java.io.IOException;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestWatchServiceAction extends WatcherRestHandler {
public RestWatchServiceAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove in 6.0
// NOTE: we switched from PUT in 2.x to POST in 5.x
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_restart", this,
PUT, "/_watcher/_restart", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_start",
new StartRestHandler(settings), PUT, "/_watcher/_start", deprecationLogger);
controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_stop",
new StopRestHandler(settings), PUT, "/_watcher/_stop", deprecationLogger);
controller.registerHandler(POST, URI_BASE + "/_start", this);
controller.registerHandler(POST, URI_BASE + "/_stop", new StopRestHandler(settings));
}
@Override
public String getName() {
return "xpack_watcher_service_action";
return "xpack_watcher_start_service_action";
}
@Override
public RestChannelConsumer doPrepareRequest(RestRequest request, WatcherClient client)
throws IOException {
return channel -> client.watcherService(new WatcherServiceRequest().stop(),
ActionListener.wrap(
stopResponse -> client.watcherService(new WatcherServiceRequest().start(),
new AcknowledgedRestListener<>(channel))
, e -> {
try {
channel.sendResponse(new BytesRestResponse(channel, e));
} catch (Exception inner) {
inner.addSuppressed(e);
logger.error("failed to send failure response", inner);
}
}));
}
private static class StartRestHandler extends WatcherRestHandler {
StartRestHandler(Settings settings) {
super(settings);
}
@Override
public String getName() {
return "xpack_watcher_start_service_action";
}
@Override
public RestChannelConsumer doPrepareRequest(RestRequest request, WatcherClient client)
throws IOException {
return channel -> client.watcherService(new WatcherServiceRequest().start(),
new AcknowledgedRestListener<>(channel));
}
return channel -> client.watcherService(new WatcherServiceRequest().start(),
new AcknowledgedRestListener<>(channel));
}
private static class StopRestHandler extends WatcherRestHandler {

View File

@ -22,12 +22,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
public class RestWatcherStatsAction extends WatcherRestHandler {
public RestWatcherStatsAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
controller.registerWithDeprecatedHandler(GET, URI_BASE + "/stats", this,
GET, "/_watcher/stats", deprecationLogger);
controller.registerWithDeprecatedHandler(GET, URI_BASE + "/stats/{metric}", this,
GET, "/_watcher/stats/{metric}", deprecationLogger);
controller.registerHandler(GET, URI_BASE + "/stats", this);
controller.registerHandler(GET, URI_BASE + "/stats/{metric}", this);
}
@Override

View File

@ -1,15 +0,0 @@
{
"xpack.watcher.restart": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-restart.html",
"methods": [ "POST" ],
"url": {
"path": "/_xpack/watcher/_restart",
"paths": [ "/_xpack/watcher/_restart" ],
"parts": {
},
"params": {
}
},
"body": null
}
}

View File

@ -1,8 +0,0 @@
---
"Test restart watcher api":
- do:
cluster.health:
wait_for_status: yellow
- do: {xpack.watcher.restart: {}}
- match: { acknowledged: true }