-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/38182/
-----------------------------------------------------------
Review request for Ambari, John Speidel, Robert Nettleton, and Jeff Sposetti.
Bugs: AMBARI-12989
https://issues.apache.org/jira/browse/AMBARI-12989
Repository: ambari
Description
-------
PROBLEM
When creating any resource like blueprint, cluster etc, you can specify the
resource name both in the Url and Json payload as well. For example in case of
a blueprint creation: api/v1/blueprints/sandboxURL Json:
{"Blueprints":{"blueprint_name":"sandboxJson"}}. In this case the blueprint
will be created as sandboxJson so the name specified in Json will override the
name specifie din the Url. The behavoir is true for cluster creation and any
other resource where you can specify name in Json as well. This could be a bit
misleading so the API may return an error in case of resource names don't match.
SOLUTION
The solution would be to throw an error message (Error code 400) in case
resource names are different. To achive this only for cluster creation would be
quite complicated since resource handling is quite generic and in
ClusterResourceProvider - which contains resource specific handling - only the
request body is available, the url is not. The actual behaviour is that in
PersistenceManagerImpl.create method the resource name (eg. blueprint_name) is
inserted from the url in Json in case it's missing. So if resource name is
specified in url than that will be used, if is specified both url and Json then
latter will be used. Because of this behaviour I think we should hadnle this
problem in PersistenceManagerImpl.create as you can see in attached patch. This
will affect of course the creation of all resources.
All unittests were
Diffs
-----
ambari-server/src/main/java/org/apache/ambari/server/api/services/persistence/PersistenceManagerImpl.java
4db5611
ambari-server/src/test/java/org/apache/ambari/server/api/services/PersistenceManagerImplTest.java
9ff1506
Diff: https://reviews.apache.org/r/38182/diff/
Testing
-------
Manually tested blueprint and cluster creation, then cluster creation with
blueprint. All unitests passed, it seems it doesn't affect normal functionality.
Thanks,
Sandor Magyari