This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 2cf36ba  AMBARI-25449. Fix bulk delete api, response code 400 - Bulk 
DELETE API is broken (#3163) (praveenkjvs via dgrinenko)
2cf36ba is described below

commit 2cf36ba9605c9302f04e63848b609249d036fbe3
Author: praveenkjvs <praveenk...@gmail.com>
AuthorDate: Tue Dec 17 08:08:49 2019 -0800

    AMBARI-25449. Fix bulk delete api, response code 400 - Bulk DELETE API is 
broken (#3163) (praveenkjvs via dgrinenko)
---
 ambari-admin/src/main/resources/ui/admin-web/bower.json            | 5 +----
 .../java/org/apache/ambari/server/api/handlers/DeleteHandler.java  | 6 ++++--
 .../ambari/server/controller/AmbariManagementControllerImpl.java   | 5 +++--
 .../controller/internal/DeleteHostComponentStatusMetaData.java     | 2 +-
 .../java/org/apache/ambari/server/state/ServiceComponentImpl.java  | 7 ++++---
 .../ambari/server/controller/AmbariManagementControllerTest.java   | 2 +-
 6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/ambari-admin/src/main/resources/ui/admin-web/bower.json 
b/ambari-admin/src/main/resources/ui/admin-web/bower.json
index 739eb3f..b814b9f 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/bower.json
+++ b/ambari-admin/src/main/resources/ui/admin-web/bower.json
@@ -19,8 +19,5 @@
     "chai": "1.8.0",
     "mocha": "1.14.0",
     "sinon": "1.10.3"
-  },
-  "resolutions": {
-    "angular": "1.7.5"
   }
-}
\ No newline at end of file
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/DeleteHandler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/DeleteHandler.java
index f0314e1..f8b0a29 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/DeleteHandler.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/DeleteHandler.java
@@ -83,8 +83,10 @@ public class DeleteHandler extends BaseManagementHandler 
implements RequestHandl
       return null;
     }
 
-    if (requestStatusMetaData.getClass() != DeleteStatusMetaData.class) {
-      throw new IllegalArgumentException("RequestStatusDetails is not of type 
DeleteStatusDetails");
+    if (!(requestStatusMetaData instanceof DeleteStatusMetaData)) {
+      throw new IllegalArgumentException(
+                 String.format("Wrong status details class received - 
expecting: %s; actual: %s", 
+                          DeleteStatusMetaData.class, 
requestStatusMetaData.getClass()));
     }
 
     DeleteStatusMetaData statusDetails = (DeleteStatusMetaData) 
requestStatusMetaData;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index cc82a2d..c6794f8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -3605,12 +3605,13 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     ServiceComponentHost componentHost = 
component.getServiceComponentHost(request.getHostname());
 
     if (!componentHost.canBeRemoved()) {
-      throw new AmbariException("Host Component cannot be removed"
+      throw new AmbariException("Current host component state prohibiting 
component removal."
               + ", clusterName=" + request.getClusterName()
               + ", serviceName=" + request.getServiceName()
               + ", componentName=" + request.getComponentName()
               + ", hostname=" + request.getHostname()
-              + ", request=" + request);
+              + ", request=" + request
+              + ", state=" + componentHost.getState());
     }
   }
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
index 7237f5b..79bc26b 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DeleteHostComponentStatusMetaData.java
@@ -37,7 +37,7 @@ public class DeleteHostComponentStatusMetaData extends 
DeleteStatusMetaData {
                                       String clusterId, String version, State 
lastComponentState) {
     removedHostComponents.add(new HostComponent(componentName, serviceName, 
hostId,
         hostName, clusterId, version, lastComponentState));
-    addDeletedKey(componentName + "/" + hostName);
+    addDeletedKey(hostName + "/" + componentName);
   }
 
   public Set<HostComponent> getRemovedHostComponents() {
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 3374521..4cfa00d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -558,14 +558,15 @@ public class ServiceComponentImpl implements 
ServiceComponent {
       ServiceComponentHost sch = getServiceComponentHost(hostname);
       LOG.info("Deleting servicecomponenthost for cluster" + ", clusterName=" 
+ getClusterName()
           + ", serviceName=" + getServiceName() + ", componentName=" + 
getName()
-          + ", recoveryEnabled=" + isRecoveryEnabled() + ", hostname=" + 
sch.getHostName());
+          + ", recoveryEnabled=" + isRecoveryEnabled() + ", hostname=" + 
sch.getHostName() + ", state=" + sch.getState());
       if (!sch.canBeRemoved()) {
-        throw new AmbariException("Could not delete hostcomponent from cluster"
+        throw new AmbariException("Current host component state prohibiting 
component removal."
             + ", clusterName=" + getClusterName()
             + ", serviceName=" + getServiceName()
             + ", componentName=" + getName()
             + ", recoveryEnabled=" + isRecoveryEnabled()
-            + ", hostname=" + sch.getHostName());
+            + ", hostname=" + sch.getHostName()
+            + ", state=" + sch.getState());
       }
       sch.delete(deleteMetaData);
       hostComponents.remove(hostname);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 92b32ef..f8b8f4a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -7927,7 +7927,7 @@ public class AmbariManagementControllerTest {
       Assert.fail("Expect failure while deleting.");
     } catch (Exception ex) {
       Assert.assertTrue(ex.getMessage().contains(
-          "Host Component cannot be removed"));
+          "Current host component state prohibiting component removal"));
     }
 
     
sc1.getServiceComponentHosts().values().iterator().next().setDesiredState(State.STARTED);

Reply via email to