-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39048/
-----------------------------------------------------------
Review request for Ambari, Jonathan Hurley and Mahadev Konar.
Bugs: AMBARI-13320
https://issues.apache.org/jira/browse/AMBARI-13320
Repository: ambari
Description
-------
A commit was merged into {{branch-2.1}} and {{branch-2.1.2}} which prevents a
rolling upgrade from starting unless the Ambari Server is a part of the
cluster. When Ambari is not a part of the cluster, a hostname is not correctly
chosen for server-side actions and the following exception is thrown at upgrade
time:
{code}
java.lang.NullPointerException
at
org.apache.ambari.server.actionmanager.ActionDBAccessorImpl.persistActions(ActionDBAccessorImpl.java:300)
at
org.apache.ambari.server.orm.AmbariJpaLocalTxnInterceptor.invoke(AmbariJpaLocalTxnInterceptor.java:68)
at
org.apache.ambari.server.actionmanager.ActionManager.sendActions(ActionManager.java:99)
at
org.apache.ambari.server.controller.internal.RequestStageContainer.persist(RequestStageContainer.java:216)
at
org.apache.ambari.server.controller.internal.UpgradeResourceProvider.createUpgrade(UpgradeResourceProvider.java:752)
at
org.apache.ambari.server.controller.internal.UpgradeResourceProvider.access$100(UpgradeResourceProvider.java:116)
at
org.apache.ambari.server.controller.internal.UpgradeResourceProvider$1.invoke(UpgradeResourceProvider.java:284)
at
org.apache.ambari.server.controller.internal.UpgradeResourceProvider$1.invoke(UpgradeResourceProvider.java:274)
at
org.apache.ambari.server.controller.internal.AbstractResourceProvider.createResources(AbstractResourceProvider.java:272)
at
org.apache.ambari.server.controller.internal.UpgradeResourceProvider.createResources(UpgradeResourceProvider.java:274)
at
org.apache.ambari.server.controller.internal.ClusterControllerImpl.createResources(ClusterControllerImpl.java:289)
{code}
The problem is the following line of code:
https://github.com/apache/ambari/blob/branch-2.1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java#L1281
{code}
String hostName = null;
Collection<Long> hostIds = cluster.getAllHostsDesiredConfigs().keySet();
if (!hostIds.isEmpty()) {
Long hostId = hostIds.iterator().next();
HostEntity hostEntity = s_hostDAO.findById(hostId);
if (hostEntity != null) {
hostName = hostEntity.getHostName();
}
}
...
stage.addServerActionCommand(task.getImplementationClass(),
Role.AMBARI_SERVER_ACTION,
RoleCommand.EXECUTE, cluster.getClusterName(),
new ServiceComponentHostServerActionEvent(null,
System.currentTimeMillis()), commandParams,
itemDetail, null, Integer.valueOf(1200), allowRetry,
context.isComponentFailureAutoSkipped());
{code}
The calculated {{hostName}} is never used to construct the server-side action.
The fix is simple - use the {{hostName}} when creating the action.
Diffs
-----
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
653419b
Diff: https://reviews.apache.org/r/39048/diff/
Testing
-------
mvn clean test
Thanks,
Dmitro Lisnichenko