Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3A804200C7F for ; Wed, 10 May 2017 01:01:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 31924160BC3; Tue, 9 May 2017 23:01:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51578160BB6 for ; Wed, 10 May 2017 01:01:57 +0200 (CEST) Received: (qmail 25433 invoked by uid 500); 9 May 2017 23:01:56 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 25422 invoked by uid 99); 9 May 2017 23:01:56 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 May 2017 23:01:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 158441AF931 for ; Tue, 9 May 2017 23:01:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.221 X-Spam-Level: X-Spam-Status: No, score=-4.221 tagged_above=-999 required=6.31 tests=[HK_RANDOM_FROM=0.001, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ZiECa6fL3arE for ; Tue, 9 May 2017 23:01:53 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id BAA125FC43 for ; Tue, 9 May 2017 23:01:52 +0000 (UTC) Received: (qmail 25409 invoked by uid 99); 9 May 2017 23:01:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 May 2017 23:01:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CC2E9DFD70; Tue, 9 May 2017 23:01:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mxmrlv@apache.org To: dev@ariatosca.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ariatosca git commit: instumented logging and node states Date: Tue, 9 May 2017 23:01:51 +0000 (UTC) archived-at: Tue, 09 May 2017 23:01:58 -0000 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 Authored: Wed May 10 02:01:47 2017 +0300 Committer: max-orlov 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}