Ravi Nori has uploaded a new change for review. Change subject: tools : Upgrades from 3.5 on should look for Command Coordinator related changes to Aysc Tasks ......................................................................
tools : Upgrades from 3.5 on should look for Command Coordinator related changes to Aysc Tasks >From 3.5 on Async Tasks exists in two different tables, async_tasks and command_entities. When upgrading from 3.5.x to higher versions we need to check if there any rows in command_entities table where callback_enabled is true and callback_notified is false. If there are any rows upgrades should not be allowed. Change-Id: Ib2c240301cd37df195d60fd8949cd45de78f183e Bug-Url: https://bugzilla.redhat.com/1108162 Signed-off-by: Ravi Nori <rn...@redhat.com> --- M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/asynctasks.py 1 file changed, 79 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/28965/1 diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/asynctasks.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/asynctasks.py index 94c8e91..a6d551c 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/asynctasks.py +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/upgrade/asynctasks.py @@ -193,6 +193,66 @@ ] ) + def _getCommandEntitiesTableExists(self, dbstatement): + + command_entities = dbstatement.execute( + statement=""" + select relname + from pg_class + where relname = 'command_entities' + """, + ownConnection=True, + transaction=False, + ) + + return ( + [ + _( + 'Relname: {relname:30}' + ).format( + relname=entry['relname'], + ) + for entry in command_entities + ] + ) + + def _getRunningCommands(self, dbstatement): + + if not self._getCommandEntitiesTableExists(dbstatement): + return None + + commands = dbstatement.execute( + statement=""" + select + command_entities.command_type, + command_entities.command_id, + command_entities.created_at, + command_entities.status + from command_entities + where command_entities.callback_enabled = 'true' + and command_entities.callback_notified = 'false' + """, + ownConnection=True, + transaction=False, + ) + + return ( + [ + _( + 'Command ID: {command_id:30}\n' + 'Command Type: {command_type:30}\n' + 'Created at: {created_at:30}\n' + 'Status: {status:30}' + ).format( + command_id=entry['command_id'], + command_type=entry['command_type'], + created_at=entry['created_at'], + status=entry['status'], + ) + for entry in commands + ] + ) + def _getCompensations(self, dbstatement): compensations = dbstatement.execute( @@ -211,7 +271,7 @@ ] ) - def _askUserToStopTasks(self, runningTasks, compensations): + def _askUserToStopTasks(self, runningTasks, runningCommands, compensations): self.dialog.note( text=_( 'The following system tasks have been ' @@ -219,6 +279,15 @@ '{tasks}' ).format( tasks='\n'.join(runningTasks), + ) + ) + self.dialog.note( + text=_( + 'The following commands have been ' + 'found running in the system:\n' + '{commands}' + ).format( + commands='\n'.join(runningCommands), ) ) self.dialog.note( @@ -242,7 +311,7 @@ raise RuntimeError( _( 'Upgrade cannot be completed; asynchronious tasks or ' - 'compensations are still running. Please make sure ' + 'commands or compensations are still running. Please make sure ' 'that there are no running tasks before you ' 'continue.' ) @@ -255,6 +324,7 @@ ) return ( self._getRunningTasks(dbstatement), + self._getRunningCommands(dbstatement), self._getCompensations(dbstatement), ) @@ -264,9 +334,10 @@ parent=self, ): while True: - runningTasks, compensations = self._checkRunningTasks() + runningTasks, runningCommands, compensations = self._checkRunningTasks() if ( not runningTasks and + not runningCommands and not compensations ): break @@ -282,7 +353,7 @@ oenginecons.AsyncTasksEnv. CLEAR_TASKS_WAIT_PERIOD ], - number=len(runningTasks + compensations), + number=len(runningTasks + runningCommands + compensations), ) ) time.sleep( @@ -346,9 +417,9 @@ self.logger.info( _('Cleaning async tasks and compensations') ) - runningTasks, compensations = self._checkRunningTasks() - if runningTasks or compensations: - self._askUserToStopTasks(runningTasks, compensations) + runningTasks, runningCommands, compensations = self._checkRunningTasks() + if runningTasks or runningCommands or compensations: + self._askUserToStopTasks(runningTasks, runningCommands, compensations) dbstatement = database.Statement( dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS, environment=self.environment, @@ -359,7 +430,7 @@ self.logger.error( _( 'Upgrade cannot be completed; asynchronious tasks ' - 'or compensations are still running. Please make ' + 'or commands or compensations are still running. Please make ' 'sure that there are no running tasks before you ' 'continue.' ) -- To view, visit http://gerrit.ovirt.org/28965 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib2c240301cd37df195d60fd8949cd45de78f183e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches