ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: instumented logging and node states
Date Tue, 09 May 2017 23:01:51 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue 5194ad2ac -> 20a285408


instumented logging and node states


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/20a28540
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/20a28540
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/20a28540

Branch: refs/heads/ARIA-213-Sporadic-tests-failures-over-locked-database-issue
Commit: 20a2854081c0edaf88a7d347097f49b32f46748f
Parents: 5194ad2
Author: max-orlov <maxim@gigaspaces.com>
Authored: Wed May 10 02:01:47 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Wed May 10 02:01:47 2017 +0300

----------------------------------------------------------------------
 .../workflows/core/events_handler.py            |  6 ++---
 aria/storage/instrumentation.py                 | 26 +++++++++++++-------
 examples/hello-world/scripts/configure.sh       |  5 ++--
 examples/hello-world/scripts/start.sh           | 14 +++++------
 examples/hello-world/scripts/stop.sh            |  4 +--
 5 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/20a28540/aria/orchestrator/workflows/core/events_handler.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/core/events_handler.py b/aria/orchestrator/workflows/core/events_handler.py
index f3e4e7e..325478d 100644
--- a/aria/orchestrator/workflows/core/events_handler.py
+++ b/aria/orchestrator/workflows/core/events_handler.py
@@ -40,7 +40,7 @@ def _task_started(task, *args, **kwargs):
     with task._update():
         task.started_at = datetime.utcnow()
         task.status = task.STARTED
-        _update_node_state_if_necessary(task, is_transitional=True)
+    _update_node_state_if_necessary(task, is_transitional=True)
 
 
 @events.on_failure_task_signal.connect
@@ -74,7 +74,7 @@ def _task_succeeded(task, *args, **kwargs):
         task.ended_at = datetime.utcnow()
         task.status = task.SUCCESS
 
-        _update_node_state_if_necessary(task)
+    _update_node_state_if_necessary(task)
 
 
 @events.start_workflow_signal.connect
@@ -143,7 +143,7 @@ def _update_node_state_if_necessary(task, is_transitional=False):
         state = node.determine_state(op_name=task.operation_name, is_transitional=is_transitional)
         if state:
             node.state = state
-            task.context.model.node.update(node)
+            # task.context.model.node.update(node)
 
 
 def _log_tried_to_cancel_execution_but_it_already_ended(workflow_context, status):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/20a28540/aria/storage/instrumentation.py
----------------------------------------------------------------------
diff --git a/aria/storage/instrumentation.py b/aria/storage/instrumentation.py
index 14d4423..8bb5d5d 100644
--- a/aria/storage/instrumentation.py
+++ b/aria/storage/instrumentation.py
@@ -13,9 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import os
 import copy
-import json
 
 import sqlalchemy.event
 
@@ -26,9 +24,14 @@ from ..storage.exceptions import StorageError
 _VERSION_ID_COL = 'version'
 _STUB = object()
 _INSTRUMENTED = {
+    # Node related stuff
     _models.Node.runtime_properties: dict,
+    _models.Node.state: str,
 
-    # Log related stuff
+    # # Task related stuff
+    _models.Task.status: str,
+
+    # # Log related stuff
     _models.Log.level: str,
     _models.Log.msg: str,
     _models.Log.traceback: str,
@@ -189,12 +192,16 @@ def apply_tracked_changes(tracked_changes, model):
                             # The object can be entirely new (Log is an example of this use
case,
                             # its id is None (or 'null'), thus we need to create it from
scratch,
                             # and not just update it.
-                            instance = mapi.model_cls() if 'null' else mapi.get(instance_id)
+                            if instance_id in ('null', None):
+                                instance = mapi.model_cls()
+                            else:
+                                instance = mapi.get(instance_id)
+
                         setattr(instance, attribute_name, value.current)
                 if instance:
                     _validate_version_id(instance, mapi)
                     # This follows the same logic as the same comment regarding 'null'
-                    if instance_id == 'null':
+                    if instance_id in ('null', None):
                         mapi.put(instance)
                     else:
                         mapi.update(instance)
@@ -204,10 +211,11 @@ def apply_tracked_changes(tracked_changes, model):
         for key, value in successfully_updated_changes.items():
             if not value:
                 del successfully_updated_changes[key]
-        model.logger.error(
-            'Registering all the changes to the storage has failed. {0}'
-            'The successful updates were: {0} '
-            '{1}'.format(os.linesep, json.dumps(successfully_updated_changes, indent=4)))
+        # TODO: if the successful has _STUB, the logging fails because it can't serialize
the object
+        # model.logger.error(
+        #     'Registering all the changes to the storage has failed. {0}'
+        #     'The successful updates were: {0} '
+        #     '{1}'.format(os.linesep, json.dumps(successfully_updated_changes, indent=4)))
 
         raise
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/20a28540/examples/hello-world/scripts/configure.sh
----------------------------------------------------------------------
diff --git a/examples/hello-world/scripts/configure.sh b/examples/hello-world/scripts/configure.sh
index b55ec17..781272b 100755
--- a/examples/hello-world/scripts/configure.sh
+++ b/examples/hello-world/scripts/configure.sh
@@ -8,7 +8,7 @@ if [ -d ${PYTHON_FILE_SERVER_ROOT} ]; then
 	echo "Removing file server root folder ${PYTHON_FILE_SERVER_ROOT}"
 	rm -rf ${PYTHON_FILE_SERVER_ROOT}
 fi
-ctx logger info "Creating HTTP server root directory at ${PYTHON_FILE_SERVER_ROOT}"
+#ctx logger info "Creating HTTP server root directory at ${PYTHON_FILE_SERVER_ROOT}"
 
 mkdir -p ${PYTHON_FILE_SERVER_ROOT}
 
@@ -17,7 +17,8 @@ cd ${PYTHON_FILE_SERVER_ROOT}
 index_path="index.html"
 image_path="images/aria-logo.png"
 
-ctx logger info "Downloading blueprint resources..."
+#ctx logger info "Downloading blueprint resources..."
+#ctx logger info "ya"
 ctx download-resource-and-render ${PYTHON_FILE_SERVER_ROOT}/index.html ${index_path}
 ctx download-resource ${PYTHON_FILE_SERVER_ROOT}/aria-logo.png ${image_path}
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/20a28540/examples/hello-world/scripts/start.sh
----------------------------------------------------------------------
diff --git a/examples/hello-world/scripts/start.sh b/examples/hello-world/scripts/start.sh
index 96298c5..03c59d4 100755
--- a/examples/hello-world/scripts/start.sh
+++ b/examples/hello-world/scripts/start.sh
@@ -6,16 +6,16 @@ TEMP_DIR="/tmp"
 PYTHON_FILE_SERVER_ROOT=${TEMP_DIR}/python-simple-http-webserver
 PID_FILE="server.pid"
 
-ctx logger info "Starting HTTP server from ${PYTHON_FILE_SERVER_ROOT}"
+#ctx logger info "Starting HTTP server from ${PYTHON_FILE_SERVER_ROOT}"
 
 port=$(ctx node properties port)
 
 cd ${PYTHON_FILE_SERVER_ROOT}
-ctx logger info "Starting SimpleHTTPServer"
+#ctx logger info "Starting SimpleHTTPServer"
 nohup python -m SimpleHTTPServer ${port} > /dev/null 2>&1 &
 echo $! > ${PID_FILE}
 
-ctx logger info "Waiting for server to launch on port ${port}"
+#ctx logger info "Waiting for server to launch on port ${port}"
 url="http://localhost:${port}"
 
 server_is_up() {
@@ -28,7 +28,7 @@ server_is_up() {
 			return 0
 		fi
 	else
-		ctx logger error "Both curl, wget were not found in path"
+#		ctx logger error "Both curl, wget were not found in path"
 		exit 1
 	fi
 	return 1
@@ -38,15 +38,15 @@ STARTED=false
 for i in $(seq 1 15)
 do
 	if server_is_up; then
-		ctx logger info "Server is up."
+#		ctx logger info "Server is up."
 		STARTED=true
     	break
 	else
-		ctx logger info "Server not up. waiting 1 second."
+#		ctx logger info "Server not up. waiting 1 second."
 		sleep 1
 	fi
 done
 if [ ${STARTED} = false ]; then
-	ctx logger error "Failed starting web server in 15 seconds."
+#	ctx logger error "Failed starting web server in 15 seconds."
 	exit 1
 fi

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/20a28540/examples/hello-world/scripts/stop.sh
----------------------------------------------------------------------
diff --git a/examples/hello-world/scripts/stop.sh b/examples/hello-world/scripts/stop.sh
index 5461caf..63e1971 100755
--- a/examples/hello-world/scripts/stop.sh
+++ b/examples/hello-world/scripts/stop.sh
@@ -8,8 +8,8 @@ PID_FILE="server.pid"
 
 PID=`cat ${PYTHON_FILE_SERVER_ROOT}/${PID_FILE}`
 
-ctx logger info "Shutting down file server. pid = ${PID}"
+#ctx logger info "Shutting down file server. pid = ${PID}"
 kill -9 ${PID} || exit $?
 
-ctx logger info "Deleting file server root directory (${PYTHON_FILE_SERVER_ROOT})"
+#ctx logger info "Deleting file server root directory (${PYTHON_FILE_SERVER_ROOT})"
 rm -rf ${PYTHON_FILE_SERVER_ROOT}


Mime
View raw message