Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.1.2
-
None
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:
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)
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
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());
The calculated hostName is never used to construct the server-side action. The fix is simple - use the hostName when creating the action.
Attachments
Attachments
Issue Links
- links to