private Long getActiveUpgradeRequestId(Cluster cluster) {

    // May be null, and either upgrade or downgrade
    UpgradeEntity currentUpgrade = cluster.getUpgradeInProgress();
    if (currentUpgrade == null) {
      LOG.debug("There is no active upgrade in progress. Skip retrying failed tasks.");
      return null;
    }

    Direction direction = currentUpgrade.getDirection();
    RepositoryVersionEntity repositoryVersion = currentUpgrade.getRepositoryVersion();

    LOG.debug(
        "Found an active upgrade with id: {}, direction: {}, {} {}", currentUpgrade.getId(),
        direction, currentUpgrade.getUpgradeType(), direction.getPreposition(),
        repositoryVersion.getVersion());

    return currentUpgrade.getRequestId();
  }
Get the Request Id of the most recent stack upgrade if it is active.
@param cluster Cluster
@return Request Id of active stack upgrade.
ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java