Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: changed tasks polling in engine-upgrade
......................................................................

packaging: changed tasks polling in engine-upgrade

Modified checkRunningTasks: during engine upgrade, sample the current
situation of asynchronous tasks and compensations and continue the
upgrade as soon as tasks are cleared.
Every ~3 minutes (MAINTENANCE_TASKS_WAIT_PERIOD) if there are async
tasks still around, allows the user to retry or abort.
The user can retry for 20 times (MAINTENANCE_TASKS_CYCLES) before
the upgrade is aborted automatically.

Fixed a small typo in MSG_ERROR_FAILED_CONVERT_ENGINE_KEY.

Change-Id: I32eaeb2427fcc9c4566ca12bf547d49a308a8937
Bug-Url: https://bugzilla.redhat.com/877749
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M packaging/fedora/setup/engine-upgrade.py
1 file changed, 32 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/77/12177/1

diff --git a/packaging/fedora/setup/engine-upgrade.py 
b/packaging/fedora/setup/engine-upgrade.py
index 03e9a5b..095145b 100755
--- a/packaging/fedora/setup/engine-upgrade.py
+++ b/packaging/fedora/setup/engine-upgrade.py
@@ -90,7 +90,7 @@
 MSG_ERROR_PGPASS = "Error: DB password file was not found on this system. 
Verify \
 that this system was previously installed and that there's a password file at 
%s or %s" % \
 (basedefs.DB_PASS_FILE, basedefs.ORIG_PASS_FILE)
-MSG_ERROR_FAILED_CONVERT_ENGINE_KEY = "Error: Can't convert engine key to 
PKCS#12 fomat"
+MSG_ERROR_FAILED_CONVERT_ENGINE_KEY = "Error: Can't convert engine key to 
PKCS#12 format"
 MSG_ERROR_SSH_KEY_SYMLINK = "Error: SSH key should not be symlink"
 MSG_ERROR_UUID_VALIDATION_FAILED = (
     "Pre-upgade host UUID validation failed\n"
@@ -847,7 +847,19 @@
     else:
         return compensations
 
+
 def checkRunningTasks(dbName=basedefs.DB_NAME, 
service=basedefs.ENGINE_SERVICE_NAME):
+    """
+    Sample the current situation of asynchronous
+    tasks and compensations and continue the upgrade as soon as tasks are
+    cleared.
+
+    Every MAINTENANCE_TASKS_WAIT_PERIOD seconds if there are asynchronous
+    tasks still around, allows the user to retry or abort.
+
+    The user can retry for MAINTENANCE_TASKS_CYCLES times before the upgrade is
+    aborted automatically.
+    """
     # Find running tasks first
     logging.debug(MSG_RUNNING_TASKS)
     deployDbAsyncTasks(dbName)
@@ -882,7 +894,6 @@
                                                   
engineConfigBin=engineConfigBinary,
                                                   
engineConfigExtended=engineConfigExtended)
 
-
         try:
 
             # Enter maintenance mode
@@ -897,14 +908,29 @@
             # Pull tasks in a loop for some time
             # MAINTENANCE_TASKS_WAIT_PERIOD  = 180 (seconds, between trials)
             # MAINTENANCE_TASKS_CYCLES = 20 (how many times to try)
+            seconds_waited = 0
+            retry_counter = 0
             while runningTasks or compensations:
-                time.sleep(MAINTENANCE_TASKS_WAIT_PERIOD)
+                time.sleep(1)
+                seconds_waited += 1
                 runningTasks = getRunningTasks(dbName)
                 compensations = getCompensations(dbName)
                 logging.debug(MSG_WAITING_RUNNING_TASKS)
 
-                # Show the list of tasks to the user, ask what to do
                 if runningTasks or compensations:
+                    if seconds_waited < MAINTENANCE_TASKS_WAIT_PERIOD:
+                        continue
+
+                    retry_counter += 1
+                    running_tasks_msg = MSG_TASKS_COMPENSATIONS % (
+                        runningTasks, compensations
+                    )
+                    if retry_counter >= MAINTENANCE_TASKS_CYCLES:
+                        # There are still tasks running, so exit and tell to 
resolve
+                        # before user continues.
+                        raise Exception(MSG_TASKS_STILL_RUNNING % 
running_tasks_msg)
+
+                    # Show the list of tasks to the user, ask what to do
                     timestamp = "\n[ " + utils.getCurrentDateTimeHuman() + " ] 
"
                     stopTasksQuestion = MSG_STOP_RUNNING_TASKS % (
                                          MSG_TASKS_COMPENSATIONS % 
(runningTasks, compensations),
@@ -917,13 +943,12 @@
                     if not answerYes:
                         # There are still tasks running, so exit and tell to 
resolve
                         # before user continues.
-                        RUNNING_TASKS_MSG = MSG_TASKS_COMPENSATIONS % 
(runningTasks, compensations)
-                        raise Exception(MSG_TASKS_STILL_RUNNING % 
RUNNING_TASKS_MSG)
+                        raise Exception(MSG_TASKS_STILL_RUNNING % 
running_tasks_msg)
 
                     logging.debug(output_messages.INFO_RETRYING + 
output_messages.INFO_STOPPING_TASKS, MAINTENANCE_TASKS_WAIT_PERIOD_MINUTES)
                     timestamp = "\n[ " + utils.getCurrentDateTimeHuman() + " ] 
"
                     print timestamp + output_messages.INFO_RETRYING + 
output_messages.INFO_STOPPING_TASKS % MAINTENANCE_TASKS_WAIT_PERIOD_MINUTES
-
+                    seconds_waited = 0
         except:
             logging.error(traceback.format_exc())
             raise
@@ -940,7 +965,6 @@
             utils.configureTasksTimeout(timeout=origTimeout,
                                         engineConfigBin=engineConfigBinary,
                                         
engineConfigExtended=engineConfigExtended)
-
 
 
 def main(options):


--
To view, visit http://gerrit.ovirt.org/12177
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32eaeb2427fcc9c4566ca12bf547d49a308a8937
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to