Alex Lourie has uploaded a new change for review. Change subject: packaging: Updated parsing of the async tasks ......................................................................
packaging: Updated parsing of the async tasks This patch adds a new SQL query for fetching the COUNT() of the async tasks to allow better parsing and not depending on the actual text. Parsing COUNT as integer makes it easier to detect running async tasks. The previously used query is then run to fetch the actual list of tasks. Change-Id: I3b1f24ef5e83cf09c01c3ebbb00375098ddc52c1 Bug-Url: https://bugzilla.redhat.com/921578 Signed-off-by: Alex Lourie <alou...@redhat.com> --- M packaging/fedora/setup/engine-upgrade.py 1 file changed, 15 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/13131/1 diff --git a/packaging/fedora/setup/engine-upgrade.py b/packaging/fedora/setup/engine-upgrade.py index f1e5835..6add4f6 100755 --- a/packaging/fedora/setup/engine-upgrade.py +++ b/packaging/fedora/setup/engine-upgrade.py @@ -40,6 +40,7 @@ LOG_PATH = "/var/log/ovirt-engine" # ASYNC TASKS AND COMPLETIONS QUERIES +ASYNC_TASKS_COUNT_QUERY = "select COUNT(*) from fn_db_get_async_tasks();" ASYNC_TASKS_QUERY = "select * from fn_db_get_async_tasks();" COMPENSATIONS_QUERY = "select command_type, entity_type from business_entity_snapshot;" @@ -827,22 +828,32 @@ out, rc = utils.execCmd(cmdList=cmd, failOnError=True, msg="Error updating DB for getting async_tasks", envDict=utils.getPgEnv()) def getRunningTasks(dbName=basedefs.DB_NAME): - # Get async tasks: + # Get async tasks count: runningTasks, rc = utils.execRemoteSqlCommand( userName=SERVER_ADMIN, dbHost=SERVER_NAME, dbPort=SERVER_PORT, dbName=dbName, - sqlQuery=ASYNC_TASKS_QUERY, + sqlQuery=ASYNC_TASKS_COUNT_QUERY, failOnError=True, errMsg="Can't get async tasks list", ) # We only want to return anything if there are really async tasks records - if runningTasks and "RECORD" in runningTasks: + # Count is the 3rd line (header, ----, count, #of rows) + if runningTasks and int(runningTasks.split('\n')[2]) > 0: + runningTasks, rc = utils.execRemoteSqlCommand( + userName=SERVER_ADMIN, + dbHost=SERVER_NAME, + dbPort=SERVER_PORT, + dbName=dbName, + sqlQuery=ASYNC_TASKS_QUERY, + failOnError=True, + errMsg="Can't get async tasks list", + ) return runningTasks else: - return "" + return '' def getCompensations(dbName=basedefs.DB_NAME): """ -- To view, visit http://gerrit.ovirt.org/13131 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3b1f24ef5e83cf09c01c3ebbb00375098ddc52c1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alex Lourie <alou...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches