Skip to content

Commit cc59af7

Browse files
authored
Merge pull request #4886 from guzzijones/patch-5
Make scheduling timeout constant to be a configurable option
2 parents f5e56ac + 580da94 commit cc59af7

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Added
1717
* Add ``get_entrypoint()`` method to ``ActionResourceManager`` attribute of st2client.
1818
#4791
1919
* Add support for orquesta task retry. (new feature)
20+
* Add config option ``scheduler.execution_scheduling_timeout_threshold_min`` to better control the cleanup of scheduled actions that were orphaned. #4886
2021

2122
Changed
2223
~~~~~~~

conf/st2.conf.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ retry_max_attempt = 10
273273
logging = /etc/st2/logging.scheduler.conf
274274
# How long (in seconds) to sleep between each action scheduler main loop run interval.
275275
sleep_interval = 0.1
276+
# How long GC to search back in minutes for orphaned scheduled actions
277+
execution_scheduling_timeout_threshold_min = 1
276278
# The size of the pool used by the scheduler for scheduling executions.
277279
pool_size = 10
278280
# The number of milliseconds to wait in between retries.

st2actions/st2actions/scheduler/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def _register_service_opts():
5050
default='/etc/st2/logging.scheduler.conf',
5151
help='Location of the logging configuration file.'
5252
),
53+
cfg.FloatOpt(
54+
'execution_scheduling_timeout_threshold_min', default=1,
55+
help='How long GC to search back in minutes for orphaned scheduled actions'),
5356
cfg.IntOpt(
5457
'pool_size', default=10,
5558
help='The size of the pool used by the scheduler for scheduling executions.'),

st2actions/st2actions/scheduler/handler.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@
4444

4545
LOG = logging.getLogger(__name__)
4646

47-
# If an ActionExecutionSchedulingQueueItemDB object hasn't been updated fore more than this amount
48-
# of milliseconds, it will be marked as "handled=False".
49-
# As soon as an item is picked by scheduler to be processed, it should be processed very fast
50-
# (< 5 seconds). If an item is still being marked as processing it likely indicates that the
51-
# scheduler process which was processing that item crashed or similar so we need to mark it as
52-
# "handling=False" so some other scheduler process can pick it up.
53-
EXECUTION_SCHEDUELING_TIMEOUT_THRESHOLD_MS = (60 * 1000)
54-
5547
# When a policy delayed execution is detected it will be try to be rescheduled by the scheduler
5648
# again in this amount of milliseconds.
5749
POLICY_DELAYED_EXECUTION_RESCHEDULE_TIME_MS = 2500
@@ -62,6 +54,14 @@ def __init__(self):
6254
self.message_type = LiveActionDB
6355
self._shutdown = False
6456
self._pool = eventlet.GreenPool(size=cfg.CONF.scheduler.pool_size)
57+
# If an ActionExecutionSchedulingQueueItemDB object hasn't been updated fore more than
58+
# this amount of milliseconds, it will be marked as "handled=False".
59+
# As soon as an item is picked by scheduler to be processed, it should be processed very
60+
# fast (< 5 seconds). If an item is still being marked as processing it likely indicates
61+
# that the scheduler process which was processing that item crashed or similar so we need
62+
# to mark it as "handling=False" so some other scheduler process can pick it up.
63+
self._execution_scheduling_timeout_threshold_ms = \
64+
cfg.CONF.scheduler.execution_scheduling_timeout_threshold_min * 60 * 1000
6565
self._coordinator = coordination_service.get_coordinator(start_heart=True)
6666
self._main_thread = None
6767
self._cleanup_thread = None
@@ -100,7 +100,7 @@ def _reset_handling_flag(self):
100100
query = {
101101
'scheduled_start_timestamp__lte': date.append_milliseconds_to_time(
102102
date.get_datetime_utc_now(),
103-
-EXECUTION_SCHEDUELING_TIMEOUT_THRESHOLD_MS
103+
-self._execution_scheduling_timeout_threshold_ms
104104
),
105105
'handling': True
106106
}

st2tests/st2tests/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ def _register_ssh_runner_opts():
283283

284284
def _register_scheduler_opts():
285285
scheduler_opts = [
286+
cfg.FloatOpt(
287+
'execution_scheduling_timeout_threshold_min', default=1,
288+
help='How long GC to search back in minutes for orphaned scheduled actions'),
286289
cfg.IntOpt(
287290
'pool_size', default=10,
288291
help='The size of the pool used by the scheduler for scheduling executions.'),

0 commit comments

Comments
 (0)