Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
AMBARI-25449. Fix bulk delete api, response code 400 - Bulk DELETE AP…
…I is broken (#3163) (praveenkjvs via dgrinenko)
  • Loading branch information
praveenkjvs authored and hapylestat committed Dec 17, 2019
1 parent f6aec32 commit 2cf36ba9605c9302f04e63848b609249d036fbe3
Showing 6 changed files with 14 additions and 13 deletions.
@@ -19,8 +19,5 @@
"chai": "1.8.0",
"mocha": "1.14.0",
"sinon": "1.10.3"
},
"resolutions": {
"angular": "1.7.5"
}
}
}
@@ -83,8 +83,10 @@ protected ResultMetadata convert(RequestStatusMetaData requestStatusMetaData) {
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;
@@ -3605,12 +3605,13 @@ private void checkIfHostComponentsInDeleteFriendlyState(ServiceComponentHostRequ
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());
}
}

@@ -37,7 +37,7 @@ public void addDeletedHostComponent(String componentName, String serviceName, St
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() {
@@ -558,14 +558,15 @@ public void deleteServiceComponentHosts(String hostname, DeleteHostComponentStat
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);
@@ -7927,7 +7927,7 @@ public void testDeleteHostComponentInVariousStates() throws Exception {
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);

0 comments on commit 2cf36ba

Please sign in to comment.