protected void updateClusterEnv() throws AmbariException {

    AmbariManagementController ambariManagementController = injector.getInstance(
        AmbariManagementController.class);
    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);

    LOG.info("Updating stack_features and stack_tools config properties.");
    Clusters clusters = ambariManagementController.getClusters();
    Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
    for (final Cluster cluster : clusterMap.values()) {

      Set<StackId> stackIds = new HashSet<>();
      for (Service service : cluster.getServices().values()) {
        stackIds.add(service.getDesiredStackId());
      }

      for (StackId stackId : stackIds) {
        Map<String, String> propertyMap = new HashMap<>();
        StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
        List<PropertyInfo> properties = stackInfo.getProperties();
        for(PropertyInfo property : properties) {
          if(property.getName().equals(ConfigHelper.CLUSTER_ENV_STACK_FEATURES_PROPERTY) ||
              property.getName().equals(ConfigHelper.CLUSTER_ENV_STACK_TOOLS_PROPERTY) ||
              property.getName().equals(ConfigHelper.CLUSTER_ENV_STACK_PACKAGES_PROPERTY)) {
            propertyMap.put(property.getName(), property.getValue());
          }
        }
        updateConfigurationPropertiesForCluster(cluster, ConfigHelper.CLUSTER_ENV, propertyMap, true, true);
      }
    }
  }
Updates {@code cluster-env} in the following ways:
<ul>
<li>Adds/Updates {@link ConfigHelper#CLUSTER_ENV_STACK_FEATURES_PROPERTY} from stack</li>
<li>Adds/Updates {@link ConfigHelper#CLUSTER_ENV_STACK_TOOLS_PROPERTY} from stack</li>
<li>Adds/Updates {@link ConfigHelper#CLUSTER_ENV_STACK_PACKAGES_PROPERTY} from stack</li>
</ul>

Note: Config properties stack_features and stack_tools should always be updated to latest values as defined
in the stack on an Ambari upgrade.
ambari-server/src/main/java/org/apache/ambari/server/upgrade/FinalUpgradeCatalog.java