You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2018/05/30 22:29:04 UTC

[ambari] branch trunk updated: [AMBARI-23989] Provide Patch or Maint Flag to Command JSON

This is an automated email from the ASF dual-hosted git repository.

ncole pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4292cab  [AMBARI-23989] Provide Patch or Maint Flag to Command JSON
4292cab is described below

commit 4292cabf5634ddf94786d43ebdecbd1a45b20e33
Author: Nate Cole <nc...@hortonworks.com>
AuthorDate: Wed May 30 17:06:21 2018 -0400

    [AMBARI-23989] Provide Patch or Maint Flag to Command JSON
---
 .../libraries/functions/upgrade_summary.py                    |  5 +++--
 .../java/org/apache/ambari/server/state/UpgradeContext.java   | 11 +++++++++++
 .../org/apache/ambari/server/state/UpgradeContextTest.java    |  9 ++++++++-
 ambari-server/src/test/python/TestStackFeature.py             |  9 ++++++---
 ambari-server/src/test/python/TestStackSelect.py              |  6 ++++--
 ambari-server/src/test/python/TestUpgradeSummary.py           |  6 ++++--
 6 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
index e231d49..0b30067 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
@@ -22,7 +22,7 @@ from collections import namedtuple
 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")
 
 
@@ -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"])
 
 
 def get_downgrade_from_version(service_name = None):
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index d5fd729..c016bc6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -971,6 +971,10 @@ public class UpgradeContext {
 
     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) {
@@ -1435,6 +1439,13 @@ public class UpgradeContext {
 
     @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;
   }
 
   /**
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeContextTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeContextTest.java
index b38b272..badd340 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeContextTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeContextTest.java
@@ -127,8 +127,11 @@ public class UpgradeContextTest extends EasyMockSupport {
 
     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();
@@ -153,7 +156,8 @@ public class UpgradeContextTest extends EasyMockSupport {
     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();
@@ -202,6 +206,7 @@ public class UpgradeContextTest extends EasyMockSupport {
     assertEquals(RepositoryType.STANDARD, context.getOrchestrationType());
     assertEquals(1, context.getSupportedServices().size());
     assertFalse(context.isPatchRevert());
+    assertFalse(context.getUpgradeSummary().isSwitchBits);
 
     verifyAll();
   }
@@ -248,6 +253,7 @@ public class UpgradeContextTest extends EasyMockSupport {
     assertEquals(RepositoryType.PATCH, context.getOrchestrationType());
     assertEquals(1, context.getSupportedServices().size());
     assertFalse(context.isPatchRevert());
+    assertTrue(context.getUpgradeSummary().isSwitchBits);
 
     verifyAll();
   }
@@ -332,6 +338,7 @@ public class UpgradeContextTest extends EasyMockSupport {
     assertEquals(RepositoryType.PATCH, context.getOrchestrationType());
     assertEquals(1, context.getSupportedServices().size());
     assertTrue(context.isPatchRevert());
+    assertTrue(context.getUpgradeSummary().isSwitchBits);
 
     verifyAll();
   }
diff --git a/ambari-server/src/test/python/TestStackFeature.py b/ambari-server/src/test/python/TestStackFeature.py
index 35c4df8..09d2d8c 100644
--- a/ambari-server/src/test/python/TestStackFeature.py
+++ b/ambari-server/src/test/python/TestStackFeature.py
@@ -196,7 +196,8 @@ class TestStackFeature(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
@@ -234,7 +235,8 @@ class TestStackFeature(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
@@ -273,7 +275,8 @@ class TestStackFeature(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
diff --git a/ambari-server/src/test/python/TestStackSelect.py b/ambari-server/src/test/python/TestStackSelect.py
index c842905..f8c5b8b 100644
--- a/ambari-server/src/test/python/TestStackSelect.py
+++ b/ambari-server/src/test/python/TestStackSelect.py
@@ -161,7 +161,8 @@ class TestStackSelect(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
@@ -200,7 +201,8 @@ class TestStackSelect(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
diff --git a/ambari-server/src/test/python/TestUpgradeSummary.py b/ambari-server/src/test/python/TestUpgradeSummary.py
index ae4aca9..a117f1a 100644
--- a/ambari-server/src/test/python/TestUpgradeSummary.py
+++ b/ambari-server/src/test/python/TestUpgradeSummary.py
@@ -97,7 +97,8 @@ class TestUpgradeSummary(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }
 
@@ -134,6 +135,7 @@ class TestUpgradeSummary(TestCase):
         "type":"rolling_upgrade",
         "isRevert":False,
         "orchestration":"STANDARD",
-        "isDowngradeAllowed": True
+        "isDowngradeAllowed": True,
+        "isSwitchBits": False
       }
     }

-- 
To stop receiving notification emails like this one, please contact
ncole@apache.org.