Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMBARI-23989] Provide Patch or Maint Flag to Command JSON #1420

Merged
merged 1 commit into from May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,7 +22,7 @@
from resource_management.libraries.script.script import Script
from resource_management.libraries.functions.constants import Direction

UpgradeSummary = namedtuple("UpgradeSummary", "type direction orchestration is_revert services is_downgrade_allowed")
UpgradeSummary = namedtuple("UpgradeSummary", "type direction orchestration is_revert services is_downgrade_allowed is_switch_bits")
UpgradeServiceSummary = namedtuple("UpgradeServiceSummary", "service_name source_stack source_version target_stack target_version")


Expand Down Expand Up @@ -101,7 +101,8 @@ def get_upgrade_summary():
return UpgradeSummary(type=upgrade_summary["type"], direction=upgrade_summary["direction"],
orchestration=upgrade_summary["orchestration"], is_revert = upgrade_summary["isRevert"],
services = service_summary_dict,
is_downgrade_allowed=upgrade_summary["isDowngradeAllowed"])
is_downgrade_allowed=upgrade_summary["isDowngradeAllowed"],
is_switch_bits=upgrade_summary["isSwitchBits"])
Copy link
Member

Choose a reason for hiding this comment

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

🥇



def get_downgrade_from_version(service_name = None):
Expand Down
Expand Up @@ -971,6 +971,10 @@ public UpgradeSummary getUpgradeSummary() {

summary.isDowngradeAllowed = isDowngradeAllowed();

// !!! a) if we are reverting, that can only happen via PATCH or MAINT
// b) if orchestration is a revertible type (on upgrade)
summary.isSwitchBits = m_isRevert || m_orchestration.isRevertable();

summary.services = new HashMap<>();

for (String serviceName : m_services) {
Expand Down Expand Up @@ -1435,6 +1439,13 @@ public static class UpgradeSummary {

@SerializedName("services")
public Map<String, UpgradeServiceSummary> services;

/**
* MAINT or PATCH upgrades are meant to just be switching the bits and no other
* incompatible changes.
*/
@SerializedName("isSwitchBits")
public boolean isSwitchBits = false;
}

/**
Expand Down
Expand Up @@ -127,8 +127,11 @@ public void setup() throws Exception {

expect(m_sourceRepositoryVersion.getId()).andReturn(1L).anyTimes();
expect(m_sourceRepositoryVersion.getStackId()).andReturn(new StackId("HDP", "2.6")).anyTimes();
expect(m_sourceRepositoryVersion.getVersion()).andReturn("2.6.0.0").anyTimes();

expect(m_targetRepositoryVersion.getId()).andReturn(99L).anyTimes();
expect(m_targetRepositoryVersion.getStackId()).andReturn(new StackId("HDP", "2.6")).anyTimes();
expect(m_targetRepositoryVersion.getVersion()).andReturn("2.6.0.2").anyTimes();

UpgradeHistoryEntity upgradeHistoryEntity = createNiceMock(UpgradeHistoryEntity.class);
expect(upgradeHistoryEntity.getServiceName()).andReturn(HDFS_SERVICE_NAME).anyTimes();
Expand All @@ -153,7 +156,8 @@ public void setup() throws Exception {
expect(m_completedRevertableUpgrade.getUpgradePackage()).andReturn(null).anyTimes();

RepositoryVersionEntity hdfsRepositoryVersion = createNiceMock(RepositoryVersionEntity.class);

expect(hdfsRepositoryVersion.getId()).andReturn(1L).anyTimes();
expect(hdfsRepositoryVersion.getStackId()).andReturn(new StackId("HDP-2.6")).anyTimes();
expect(m_hdfsService.getDesiredRepositoryVersion()).andReturn(hdfsRepositoryVersion).anyTimes();
expect(m_zookeeperService.getDesiredRepositoryVersion()).andReturn(hdfsRepositoryVersion).anyTimes();
expect(m_cluster.getService(HDFS_SERVICE_NAME)).andReturn(m_hdfsService).anyTimes();
Expand Down Expand Up @@ -202,6 +206,7 @@ public void testFullUpgrade() throws Exception {
assertEquals(RepositoryType.STANDARD, context.getOrchestrationType());
assertEquals(1, context.getSupportedServices().size());
assertFalse(context.isPatchRevert());
assertFalse(context.getUpgradeSummary().isSwitchBits);

verifyAll();
}
Expand Down Expand Up @@ -248,6 +253,7 @@ public void testPatchUpgrade() throws Exception {
assertEquals(RepositoryType.PATCH, context.getOrchestrationType());
assertEquals(1, context.getSupportedServices().size());
assertFalse(context.isPatchRevert());
assertTrue(context.getUpgradeSummary().isSwitchBits);

verifyAll();
}
Expand Down Expand Up @@ -332,6 +338,7 @@ public void testRevert() throws Exception {
assertEquals(RepositoryType.PATCH, context.getOrchestrationType());
assertEquals(1, context.getSupportedServices().size());
assertTrue(context.isPatchRevert());
assertTrue(context.getUpgradeSummary().isSwitchBits);

verifyAll();
}
Expand Down
9 changes: 6 additions & 3 deletions ambari-server/src/test/python/TestStackFeature.py
Expand Up @@ -196,7 +196,8 @@ def _get_cluster_upgrade_restart_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down Expand Up @@ -234,7 +235,8 @@ def _get_cluster_downgrade_restart_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down Expand Up @@ -273,7 +275,8 @@ def _get_cluster_downgrade_stop_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down
6 changes: 4 additions & 2 deletions ambari-server/src/test/python/TestStackSelect.py
Expand Up @@ -161,7 +161,8 @@ def _get_incomplete_cluster_simple_upgrade_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down Expand Up @@ -200,7 +201,8 @@ def _get_cluster_simple_upgrade_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down
6 changes: 4 additions & 2 deletions ambari-server/src/test/python/TestUpgradeSummary.py
Expand Up @@ -97,7 +97,8 @@ def _get_cluster_simple_upgrade_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}

Expand Down Expand Up @@ -134,6 +135,7 @@ def _get_cluster_simple_downgrade_json():
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
"isDowngradeAllowed": True
"isDowngradeAllowed": True,
"isSwitchBits": False
}
}