You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2014/06/03 14:31:25 UTC
git commit: AMBARI-5998. Custom action tasks response returns invalid
json string in structured_out attribute.(vbrodetskyi)
Repository: ambari
Updated Branches:
refs/heads/trunk 65b11d50c -> 03a458c0c
AMBARI-5998. Custom action tasks response returns invalid json string in structured_out attribute.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/03a458c0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/03a458c0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/03a458c0
Branch: refs/heads/trunk
Commit: 03a458c0c41a377328f0eaf7243fc580509c0aeb
Parents: 65b11d5
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Tue Jun 3 11:57:52 2014 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Tue Jun 3 11:57:52 2014 +0300
----------------------------------------------------------------------
.../src/main/python/ambari_agent/ActionQueue.py | 3 +-
.../test/python/ambari_agent/TestActionQueue.py | 29 ++++++++++----------
.../main/resources/custom_actions/check_host.py | 2 +-
ambari-server/src/test/python/TestCheckHost.py | 2 +-
4 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/03a458c0/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index f10737f..749e8c1 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -24,6 +24,7 @@ import traceback
import threading
import pprint
import os
+import json
from LiveStatus import LiveStatus
from shell import shellRunner
@@ -187,7 +188,7 @@ class ActionQueue(threading.Thread):
roleResult['customCommand'] = command['hostLevelParams']['custom_command']
if 'structuredOut' in commandresult:
- roleResult['structuredOut'] = str(commandresult['structuredOut'])
+ roleResult['structuredOut'] = str(json.dumps(commandresult['structuredOut']))
else:
roleResult['structuredOut'] = ''
# let ambari know that configuration tags were applied
http://git-wip-us.apache.org/repos/asf/ambari/blob/03a458c0/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index d020ad9..5c433f9 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -23,7 +23,7 @@ from unittest import TestCase
from ambari_agent.LiveStatus import LiveStatus
from ambari_agent.ActionQueue import ActionQueue
from ambari_agent.AmbariConfig import AmbariConfig
-import os, errno, time, pprint, tempfile, threading
+import os, errno, time, pprint, tempfile, threading, json
import StringIO
import sys
from threading import Thread
@@ -294,13 +294,13 @@ class TestActionQueue(TestCase):
'stderr': 'stderr',
'stdout': 'out',
'clusterName': u'cc',
- 'configurationTags': {'global': {'tag': 'v1'}},
+ 'structuredOut': '""',
'roleCommand': u'INSTALL',
'serviceName': u'HDFS',
'role': u'DATANODE',
'actionId': '1-1',
'taskId': 3,
- 'structuredOut' : '',
+ 'configurationTags': {'global': {'tag': 'v1'}},
'exitCode': 0}
self.assertEqual(len(report['reports']), 1)
self.assertEqual(report['reports'][0], expected)
@@ -333,12 +333,12 @@ class TestActionQueue(TestCase):
'stderr': 'stderr',
'stdout': 'out',
'clusterName': u'cc',
+ 'structuredOut': '""',
'roleCommand': u'INSTALL',
'serviceName': u'HDFS',
'role': u'DATANODE',
'actionId': '1-1',
'taskId': 3,
- 'structuredOut' : '',
'exitCode': 13}
self.assertEqual(len(report['reports']), 1)
self.assertEqual(report['reports'][0], expected)
@@ -365,12 +365,12 @@ class TestActionQueue(TestCase):
'stderr': 'stderr',
'stdout': 'out',
'clusterName': 'clusterName',
+ 'structuredOut': '""',
'roleCommand': 'UPGRADE',
'serviceName': 'serviceName',
'role': 'role',
'actionId': 17,
'taskId': 'taskId',
- 'structuredOut' : '',
'exitCode': 0}
self.assertEqual(len(report['reports']), 1)
self.assertEqual(report['reports'][0], expected)
@@ -403,20 +403,19 @@ class TestActionQueue(TestCase):
actionQueue = ActionQueue(config, dummy_controller)
actionQueue.execute_command(self.datanode_restart_command)
report = actionQueue.result()
- expected = {'actionId': '1-1',
+ expected = {'status': 'COMPLETED',
+ 'configurationTags': {'global': {'tag': 'v123'}},
+ 'stderr': 'stderr',
+ 'stdout': 'out',
'clusterName': u'cc',
- 'configurationTags': {'global' : { 'tag': 'v123' }},
- 'exitCode': 0,
- 'role': u'DATANODE',
+ 'structuredOut': '""',
'roleCommand': u'CUSTOM_COMMAND',
'serviceName': u'HDFS',
- 'status': 'COMPLETED',
+ 'role': u'DATANODE',
+ 'actionId': '1-1',
+ 'taskId': 9,
'customCommand': 'RESTART',
- 'stderr': 'stderr',
- 'stdout': 'out',
- 'structuredOut': '',
- 'taskId': 9
- }
+ 'exitCode': 0}
# Agent caches configurationTags if custom_command RESTART completed
self.assertEqual(len(report['reports']), 1)
self.assertEqual(expected, report['reports'][0])
http://git-wip-us.apache.org/repos/asf/ambari/blob/03a458c0/ambari-server/src/main/resources/custom_actions/check_host.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/check_host.py b/ambari-server/src/main/resources/custom_actions/check_host.py
index 800b421..f98492b 100644
--- a/ambari-server/src/main/resources/custom_actions/check_host.py
+++ b/ambari-server/src/main/resources/custom_actions/check_host.py
@@ -189,7 +189,7 @@ class CheckHost(Script):
Execute(cmd, not_if=format("[ -f /usr/lib/ambari-agent/{jdbc_name}]"), environment = environment)
except Exception, e:
message = "Error downloading JDBC connector from Ambari Server resources. Confirm you ran ambari-server setup to " \
- "install JDBC connector. Use \"ambari-server --help\" for more information. Check network access to " \
+ "install JDBC connector. Use \"ambari-server setup --help\" for more information. Check network access to " \
"Ambari Server.\n" + str(e)
print message
db_connection_check_structured_output = {"exit_code" : "1", "message": message}
http://git-wip-us.apache.org/repos/asf/ambari/blob/03a458c0/ambari-server/src/test/python/TestCheckHost.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestCheckHost.py b/ambari-server/src/test/python/TestCheckHost.py
index 3afff09..0ba0386 100644
--- a/ambari-server/src/test/python/TestCheckHost.py
+++ b/ambari-server/src/test/python/TestCheckHost.py
@@ -105,7 +105,7 @@ class TestCheckHost(TestCase):
self.assertEquals(structured_out_mock.call_args[0][0], {'db_connection_check': {'message': 'Error downloading JDBC ' \
'connector from Ambari Server resources. Confirm you ran ambari-server setup to ' \
- 'install JDBC connector. Use "ambari-server --help" for more information. Check ' \
+ 'install JDBC connector. Use "ambari-server setup --help" for more information. Check ' \
'network access to Ambari Server.\ntest exception', 'exit_code': '1'}})
self.assertEquals(format_mock.call_args_list[4][0][0], "/bin/sh -c 'cd /usr/lib/ambari-agent/ && curl -kf " \
"--retry 5 {jdbc_url} -o {jdbc_name}'")