----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/43927/ -----------------------------------------------------------
(Updated April 12, 2016, 6:37 p.m.) Review request for Ambari, Alejandro Fernandez, Zhe (Joe) Wang, Nate Cole, Sumit Mohanty, and Yusaku Sako. Bugs: AMBARI-15847 https://issues.apache.org/jira/browse/AMBARI-15847 Repository: ambari Description (updated) ------- Currently if anyone has to delete more than 1 host, a script is required to call delete host api in a loop for each host. This api takes in query and instead of failing fast on the first error, puts the best effort to delete all requested hosts. Response is a json object which has deleted keys and keys which failed to delete with exception. As there is a json response, it will always return 200 OK. It is backward compatible, for request with only one host it won't return json object and will return error code in case of exception instead of 200 OK. Diffs (updated) ----- ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java c54d30f ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java 322eab8 Diff: https://reviews.apache.org/r/43927/diff/ Testing (updated) ------- Tested different usecases including backward compatibility: {code} curl -u admin:admin -H 'X-Requested-By: ambari' -X DELETE http://c6401.ambari.apache.org:8080/api/v1/clusters/a/hosts/c6401.ambari.apache.org { "status" : 500, "message" : "org.apache.ambari.server.controller.spi.SystemException: An internal system exception occurred: Cannot remove host c6401.ambari.apache.org from a. The following roles exist, and these components must be stopped if running, and then deleted: ZOOKEEPER_SERVER" } curl -u admin:admin -H 'X-Requested-By: ambari' -X DELETE http://c6401.ambari.apache.org:8080/api/v1/clusters/a/hosts -d '{"RequestInfo":{"query":"Hosts/host_name.in(c6401.ambari.apache.org,c6402.ambari.apache.org)"}}' { "deleteResult" : [ { "error" : { "key" : "c6402.ambari.apache.org", "code" : 404, "message" : "org.apache.ambari.server.HostNotFoundException: Host not found, hostname=c6402.ambari.apache.org" } }, { "error" : { "key" : "c6401.ambari.apache.org", "code" : 500, "message" : "org.apache.ambari.server.AmbariException: Cannot remove host c6401.ambari.apache.org from a. The following roles exist, and these components must be stopped if running, and then deleted: ZOOKEEPER_SERVER" } } ] } curl -u admin:admin -H 'X-Requested-By: ambari' -X DELETE http://c6401.ambari.apache.org:8080/api/v1/clusters/a/hosts -d '{"RequestInfo":{"query":"Hosts/host_name.in(c6401.ambari.apache.org,c6402.ambari.apache.org)"}}' { "deleteResult" : [ { "deleted" : { "key" : "c6402.ambari.apache.org" } }, { "error" : { "key" : "c6401.ambari.apache.org", "code" : 500, "message" : "org.apache.ambari.server.AmbariException: Cannot remove host c6401.ambari.apache.org from a. The following roles exist, and these components must be stopped if running, and then deleted: ZOOKEEPER_SERVER" } } ] } {code} Thanks, Ajit Kumar