瀏覽代碼

AMBARI-9683. RU - version number in hostcomponentstate is reverted to older value (ncole)

Nate Cole 10 年之前
父節點
當前提交
f7d97c74b0

+ 4 - 4
ambari-common/src/main/python/resource_management/libraries/script/script.py

@@ -106,6 +106,10 @@ class Script(object):
     if os.path.exists(self.stroutfile):
       with open(self.stroutfile, 'r') as fp:
         Script.structuredOut = json.load(fp)
+
+    # version is only set in a specific way and should not be carried 
+    if "version" in Script.structuredOut:
+      del Script.structuredOut["version"]
   
   def put_structured_out(self, sout):
     curr_content = Script.structuredOut.copy()
@@ -146,10 +150,6 @@ class Script(object):
         request_version = default("/commandParams/request_version", None)
         if request_version is not None:
           return True
-        else:
-          if "version" in Script.structuredOut:
-            del Script.structuredOut["version"]
-            Script.structuredOut.update({})
       else:
         # Populate version only on base commands
         return command_name.lower() == "start" or command_name.lower() == "install" or command_name.lower() == "restart"

+ 13 - 0
ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py

@@ -116,6 +116,19 @@ class TestFlumeHandler(RMFTestCase):
     structured_out_mock.assert_called_with({'processes': []})
     self.assertNoMoreResources()
 
+  def test_struct_out(self):
+   from resource_management.libraries.script import Script
+
+   configs_path = os.path.join(RMFTestCase._getSrcFolder(),
+     "test/python/stacks", self.STACK_VERSION, "configs")
+
+   script = Script()
+   script.stroutfile = os.path.join(configs_path, "structured-out-status.json")
+   script.load_structured_out()
+
+   self.assertFalse("version" in script.structuredOut)
+    
+
   @patch("resource_management.libraries.script.Script.put_structured_out")
   @patch("glob.glob")
   @patch("sys.exit")

+ 5 - 0
ambari-server/src/test/python/stacks/2.0.6/configs/structured-out-status.json

@@ -0,0 +1,5 @@
+{
+  "securityIssuesFound": "Configuration file hdfs-site did not pass the validation. Reason: Property dfs.journalnode.keytab.file does not exist. Configuration file core-site did not pass the validation. Reason: Property hadoop.security.authentication contains an unexpected value. Expected/Actual: kerberos/simple",
+  "version": "2.2.0.0-2041",
+  "securityState": "UNSECURED"
+}