def test_processing_when_task_completed(self, mock_execution_queue_delete, mock_action_service): self.reset() liveaction_db = self._create_liveaction_db() LiveAction.publish_status(liveaction_db) liveaction_db.status = action_constants.LIVEACTION_STATUS_CANCELED LiveAction.add_or_update(liveaction_db) schedule_q_db = self.scheduling_queue._get_next_execution() scheduling_queue.get_handler()._handle_execution(schedule_q_db) mock_action_service.update_status.assert_not_called() mock_execution_queue_delete.assert_called_once() ActionExecutionSchedulingQueue.delete(schedule_q_db)
def _run_scheduler(): LOG.info('(PID=%s) Scheduler started.', os.getpid()) # Lazy load these so that decorator metrics are in place from st2actions.scheduler import (handler as scheduler_handler, entrypoint as scheduler_entrypoint) handler = scheduler_handler.get_handler() entrypoint = scheduler_entrypoint.get_scheduler_entrypoint() # TODO: Remove this try block for _cleanup_policy_delayed in v3.2. # This is a temporary cleanup to remove executions in deprecated policy-delayed status. try: handler._cleanup_policy_delayed() except Exception: LOG.exception( '(PID=%s) Scheduler unable to perform migration cleanup.', os.getpid()) # TODO: Remove this try block for _fix_missing_action_execution_id in v3.2. # This is a temporary fix to auto-populate action_execution_id. try: handler._fix_missing_action_execution_id() except Exception: LOG.exception( '(PID=%s) Scheduler unable to populate action_execution_id.', os.getpid()) try: handler.start() entrypoint.start() # Wait on handler first since entrypoint is more durable. handler.wait() or entrypoint.wait() except (KeyboardInterrupt, SystemExit): LOG.info('(PID=%s) Scheduler stopped.', os.getpid()) errors = False try: handler.shutdown() entrypoint.shutdown() except: LOG.exception('Unable to shutdown scheduler.') errors = True if errors: return 1 except: LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid()) try: handler.shutdown() entrypoint.shutdown() except: pass return 1 return 0
def _run_queuer(): LOG.info('(PID=%s) Scheduler started.', os.getpid()) # Lazy load these so that decorator metrics are in place from st2actions.scheduler import (handler as scheduler_handler, entrypoint as scheduler_entrypoint) handler = scheduler_handler.get_handler() entrypoint = scheduler_entrypoint.get_scheduler_entrypoint() try: handler.start() entrypoint.start() entrypoint.wait() except (KeyboardInterrupt, SystemExit): LOG.info('(PID=%s) Scheduler stopped.', os.getpid()) errors = False try: handler.shutdown() entrypoint.shutdown() except: LOG.exception('Unable to shutdown scheduler.') errors = True if errors: return 1 except: LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid()) return 1 return 0
def _run_scheduler(): LOG.info('(PID=%s) Scheduler started.', os.getpid()) # Lazy load these so that decorator metrics are in place from st2actions.scheduler import ( handler as scheduler_handler, entrypoint as scheduler_entrypoint ) handler = scheduler_handler.get_handler() entrypoint = scheduler_entrypoint.get_scheduler_entrypoint() # TODO: Remove this try block for _cleanup_policy_delayed in v3.2. # This is a temporary cleanup to remove executions in deprecated policy-delayed status. try: handler._cleanup_policy_delayed() except Exception: LOG.exception('(PID=%s) Scheduler unable to perform migration cleanup.', os.getpid()) # TODO: Remove this try block for _fix_missing_action_execution_id in v3.2. # This is a temporary fix to auto-populate action_execution_id. try: handler._fix_missing_action_execution_id() except Exception: LOG.exception('(PID=%s) Scheduler unable to populate action_execution_id.', os.getpid()) try: handler.start() entrypoint.start() # Wait on handler first since entrypoint is more durable. handler.wait() or entrypoint.wait() except (KeyboardInterrupt, SystemExit): LOG.info('(PID=%s) Scheduler stopped.', os.getpid()) errors = False try: handler.shutdown() entrypoint.shutdown() except: LOG.exception('Unable to shutdown scheduler.') errors = True if errors: return 1 except: LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid()) try: handler.shutdown() entrypoint.shutdown() except: pass return 1 return 0
def _run_scheduler(): LOG.info('(PID=%s) Scheduler started.', os.getpid()) # Lazy load these so that decorator metrics are in place from st2actions.scheduler import ( handler as scheduler_handler, entrypoint as scheduler_entrypoint ) handler = scheduler_handler.get_handler() entrypoint = scheduler_entrypoint.get_scheduler_entrypoint() try: handler.start() entrypoint.start() # Wait on handler first since entrypoint is more durable. handler.wait() or entrypoint.wait() except (KeyboardInterrupt, SystemExit): LOG.info('(PID=%s) Scheduler stopped.', os.getpid()) errors = False try: handler.shutdown() entrypoint.shutdown() except: LOG.exception('Unable to shutdown scheduler.') errors = True if errors: return 1 except: LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid()) try: handler.shutdown() entrypoint.shutdown() except: pass return 1 return 0
def main(): config.parse_args() # Connect to db. db_setup() try: handler = scheduler_handler.get_handler() handler._cleanup_policy_delayed() LOG.info('SUCCESS: Completed clean up of executions with deprecated policy-delayed status.') exit_code = 0 except Exception as e: LOG.error( 'ABORTED: Clean up of executions with deprecated policy-delayed status aborted on ' 'first failure. %s' % e.message ) exit_code = 1 # Disconnect from db. db_teardown() sys.exit(exit_code)
def process(cls, payload): ex_req = scheduling.get_scheduler_entrypoint().process(payload) if ex_req is not None: scheduling_queue.get_handler()._handle_execution(ex_req)
def _process_scheduling_queue(): for queued_req in ActionExecutionSchedulingQueue.get_all(): scheduling_queue.get_handler()._handle_execution(queued_req)
def setUp(self): super(ActionExecutionSchedulingQueueItemDBTest, self).setUp() self.scheduler = scheduling.get_scheduler_entrypoint() self.scheduling_queue = scheduling_queue.get_handler()
def __init__(self, *args, **kwargs): super(QueueConsumerTest, self).__init__(*args, **kwargs) self.scheduler = scheduling.get_scheduler_entrypoint() self.scheduling_queue = scheduling_queue.get_handler() self.dispatcher = worker.get_worker()