You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/07/06 18:26:36 UTC
ambari git commit: AMBARI-21412 - Cluster Effective Version Can Be
Cached Incorrectly During an Upgrade (jonathanhurley)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-21348 3cc61316c -> fa585fb4f
AMBARI-21412 - Cluster Effective Version Can Be Cached Incorrectly During an Upgrade (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fa585fb4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fa585fb4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fa585fb4
Branch: refs/heads/branch-feature-AMBARI-21348
Commit: fa585fb4f9b96e5c5edd5b5cba887f1c7e8425ca
Parents: 3cc6131
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Thu Jul 6 00:30:19 2017 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Thu Jul 6 14:26:26 2017 -0400
----------------------------------------------------------------------
.../upgrades/UpdateDesiredStackAction.java | 4 ++-
.../server/state/cluster/ClusterImpl.java | 32 ++++++++++++--------
2 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fa585fb4/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
index b071914..498fb49 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
@@ -82,10 +82,12 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
cluster.getUpgradeInProgress());
+ CommandReport commandReport = updateDesiredStack(cluster, context);
+
// invalidate any cached effective ID
cluster.invalidateUpgradeEffectiveVersion();
- return updateDesiredStack(cluster, context);
+ return commandReport;
}
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/fa585fb4/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index db67807..10e9ed4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -112,6 +112,7 @@ import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
import org.apache.ambari.server.orm.entities.UpgradeItemEntity;
import org.apache.ambari.server.security.authorization.AuthorizationException;
import org.apache.ambari.server.security.authorization.AuthorizationHelper;
+import org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.ClusterHealthReport;
import org.apache.ambari.server.state.Clusters;
@@ -1038,6 +1039,7 @@ public class ClusterImpl implements Cluster {
Long upgradeId = upgradeEntity.getId();
Long effectiveClusterVersionId = upgradeEffectiveVersionCache.get(upgradeId);
if (null == effectiveClusterVersionId) {
+ boolean updateCache = true;
final ClusterVersionEntity effectiveClusterVersion;
if (upgradeEntity.getUpgradeType() != UpgradeType.NON_ROLLING) {
@@ -1046,7 +1048,10 @@ public class ClusterImpl implements Cluster {
clusterName, repositoryVersion.getStackId(), repositoryVersion.getVersion());
} else {
if (upgradeEntity.getDirection() == Direction.UPGRADE) {
- boolean pastChangingStack = isNonRollingUpgradePastUpgradingStack(upgradeEntity);
+ HostRoleStatus stackActionStatus = getExpressUpgradeDesiredStackStatus(upgradeEntity);
+ boolean pastChangingStack = stackActionStatus == HostRoleStatus.COMPLETED;
+ updateCache = stackActionStatus != HostRoleStatus.IN_PROGRESS;
+
RepositoryVersionEntity repositoryVersion = pastChangingStack
? upgradeEntity.getToRepositoryVersion() : upgradeEntity.getFromRepositoryVersion();
@@ -1060,8 +1065,8 @@ public class ClusterImpl implements Cluster {
}
}
- // cache for later use
- if (null != effectiveClusterVersion) {
+ // cache for later use, but only if the action is completed
+ if (null != effectiveClusterVersion && updateCache) {
effectiveClusterVersionId = effectiveClusterVersion.getId();
upgradeEffectiveVersionCache.put(upgradeId, effectiveClusterVersionId);
}
@@ -1077,11 +1082,14 @@ public class ClusterImpl implements Cluster {
}
/**
- * Given a NonRolling stack upgrade, determine if it has already crossed the point of using the newer version.
- * @param upgrade Stack Upgrade
- * @return Return true if should be using to_version, otherwise, false to mean the from_version.
+ * Gets the status of the {@link UpdateDesiredStackAction} for an express
+ * upgrade.
+ *
+ * @param upgrade
+ * Stack Upgrade
+ * @return the status of the command
*/
- private boolean isNonRollingUpgradePastUpgradingStack(UpgradeEntity upgrade) {
+ private HostRoleStatus getExpressUpgradeDesiredStackStatus(UpgradeEntity upgrade) {
for (UpgradeGroupEntity group : upgrade.getUpgradeGroups()) {
if (group.getName().equalsIgnoreCase(UpgradeResourceProvider.CONST_UPGRADE_GROUP_NAME)) {
for (UpgradeItemEntity item : group.getItems()) {
@@ -1089,16 +1097,16 @@ public class ClusterImpl implements Cluster {
List<HostRoleCommandEntity> commands = hostRoleCommandDAO.findByPKs(taskIds);
for (HostRoleCommandEntity command : commands) {
if (command.getCustomCommandName() != null &&
- command.getCustomCommandName().equalsIgnoreCase(UpgradeResourceProvider.CONST_CUSTOM_COMMAND_NAME) &&
- command.getStatus() == HostRoleStatus.COMPLETED) {
- return true;
+ command.getCustomCommandName().equalsIgnoreCase(
+ UpgradeResourceProvider.CONST_CUSTOM_COMMAND_NAME)) {
+ return command.getStatus();
}
}
}
- return false;
+ return HostRoleStatus.PENDING;
}
}
- return false;
+ return HostRoleStatus.PENDING;
}
/**