Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
import org.apache.ambari.server.orm.entities.RequestEntity;
import org.apache.ambari.server.orm.entities.StackEntity;
import org.apache.ambari.server.orm.entities.UpgradeEntity;
import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
import org.apache.ambari.server.orm.entities.UpgradeHistoryEntity;
Expand Down Expand Up @@ -755,7 +756,17 @@ major stack versions (e.g., HDP 2.2 -> 2.3), and then set config changes
at the appropriate moment during the orchestration.
*/
if (pack.getType() == UpgradeType.ROLLING || pack.getType() == UpgradeType.HOST_ORDERED) {
if (direction == Direction.UPGRADE) {
StackEntity targetStack = upgradeContext.getRepositoryVersion().getStack();
cluster.setDesiredStackVersion(
new StackId(targetStack.getStackName(), targetStack.getStackVersion()));
}
s_upgradeHelper.updateDesiredRepositoriesAndConfigs(upgradeContext);
if (direction == Direction.DOWNGRADE) {
StackId targetStack = upgradeContext.getCluster().getCurrentStackVersion();
cluster.setDesiredStackVersion(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you already have a StackId, no need to make a new one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, did you happen to test an EU?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested EU, works well

new StackId(targetStack.getStackName(), targetStack.getStackVersion()));
}
}

// resolve or build a proper config upgrade pack - always start out with the config pack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
package org.apache.ambari.server.upgrade;

import java.sql.SQLException;
import java.util.Map;

import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.StackId;

import com.google.inject.Inject;
import com.google.inject.Injector;
Expand Down Expand Up @@ -61,6 +66,29 @@ private void addHostRequestStatusColumn() throws SQLException {

@Override
protected void executePreDMLUpdates() throws AmbariException, SQLException {
fixDesiredStack();
}

/**
* if desired stack < current stack, set current stack as desired
*
* @throws AmbariException
*/
private void fixDesiredStack() throws AmbariException {
AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
Clusters clusters = ambariManagementController.getClusters();
if (clusters != null) {
Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
if (clusterMap != null && !clusterMap.isEmpty()) {
for (final Cluster cluster : clusterMap.values()) {
StackId desiredStack = cluster.getDesiredStackVersion();
StackId currentStack = cluster.getCurrentStackVersion();
if (desiredStack.compareTo(currentStack) < 0) {
cluster.setDesiredStackVersion(currentStack);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If desired stack is > current stack, that's also a problem. Can you change this to a !equals() call instead?

@ghost ghost Feb 14, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that user is not expected to perform Ambari upgrade with a paused stack upgrade? Ok, will change the logic

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-hurley , regarding

Why does express not have this problem? 

EU updates cluster desired version during upgrade and downgrade at UpdateDesiredRepositoryAction. This action is called only from EU upgrade packs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I expected. However, I didn't see it in there. Can you identify where exactly it's set?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org/apache/ambari/server/serveraction/upgrades/UpdateDesiredRepositoryAction.java:149
at updateDesiredRepositoryVersion()

        // move the cluster's desired stack as well
        StackId targetStackId = targetRepositoryVersion.getStackId();
        cluster.setDesiredStackVersion(targetStackId);
      }

and below at the same file for downgrade.
EU was not broken, this code is already at 2.6 branch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking in trunk :)

Thanks!

}
}
}
}

@Override
Expand Down