You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/08/28 20:29:46 UTC
ambari git commit: AMBARI-12890: Ambari Server and Agent should be
more resilent when disk full (Nahappan Somasundaram via jluniya)
Repository: ambari
Updated Branches:
refs/heads/trunk 3bccd97a7 -> c472279bf
AMBARI-12890: Ambari Server and Agent should be more resilent when disk full (Nahappan Somasundaram via jluniya)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c472279b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c472279b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c472279b
Branch: refs/heads/trunk
Commit: c472279bf6f58a8debfe28352b41067efc74af85
Parents: 3bccd97
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Fri Aug 28 11:29:40 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Fri Aug 28 11:29:40 2015 -0700
----------------------------------------------------------------------
.../resource_management/libraries/script/script.py | 9 ++++++++-
.../src/test/python/stacks/2.0.6/FLUME/test_flume.py | 15 +++++++++++++++
.../2.0.6/configs/structured-out-status-bad.json | 1 +
3 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c472279b/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index 26fd158..d86e543 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -95,6 +95,7 @@ class Script(object):
basedir = ""
stroutfile = ""
logging_level = ""
+ logger = None
# Class variable
tmp_dir = ""
@@ -110,7 +111,12 @@ class Script(object):
Script.structuredOut = {}
if os.path.exists(self.stroutfile):
with open(self.stroutfile, 'r') as fp:
- Script.structuredOut = json.load(fp)
+ try:
+ Script.structuredOut = json.load(fp)
+ except Exception:
+ errMsg = 'Unable to read structured output from ' + self.stroutfile
+ self.logger.warn(errMsg)
+ pass
# version is only set in a specific way and should not be carried
if "version" in Script.structuredOut:
@@ -178,6 +184,7 @@ class Script(object):
print USAGE.format(os.path.basename(sys.argv[0])) # print to stdout
sys.exit(1)
+ self.logger = logger
self.command_name = str.lower(sys.argv[1])
self.command_data_file = sys.argv[2]
self.basedir = sys.argv[3]
http://git-wip-us.apache.org/repos/asf/ambari/blob/c472279b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
index c3722c6..be2b87c 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py
@@ -163,6 +163,21 @@ class TestFlumeHandler(RMFTestCase):
self.assertFalse("version" in script.structuredOut)
+ @patch("resource_management.libraries.script.Script.logger", autospec = True)
+ def test_bad_struct_out(self, logger_mock):
+ from resource_management.libraries.script import Script
+
+ logger_mock.warn = MagicMock()
+
+ configs_path = os.path.join(RMFTestCase.get_src_folder(),
+ "test/python/stacks", self.STACK_VERSION, "configs")
+
+ script = Script()
+ script.stroutfile = os.path.join(configs_path, "structured-out-status-bad.json")
+ script.load_structured_out()
+
+ self.assertTrue(logger_mock.warn.called)
+ self.assertTrue(script.structuredOut == {})
@patch("resource_management.libraries.script.Script.put_structured_out")
@patch("glob.glob")
http://git-wip-us.apache.org/repos/asf/ambari/blob/c472279b/ambari-server/src/test/python/stacks/2.0.6/configs/structured-out-status-bad.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/structured-out-status-bad.json b/ambari-server/src/test/python/stacks/2.0.6/configs/structured-out-status-bad.json
new file mode 100644
index 0000000..d53f425
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/structured-out-status-bad.json
@@ -0,0 +1 @@
+{"securityState" : "UNKNOWN