Skip to content

Commit d22d457

Browse files
committed
poller: make recheck timing configurable
Longer recheck is useful if the poller crashes and we want to catch up with old work. Make it configurable via: [poller] recheck_period=3 recheck_lookback=9 The above are defaults. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 99614d0 commit d22d457

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

CONFIG.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Config syntax
2+
~~~~~~~~~~~~~
3+
4+
This document describes the fields of the config file and their meaning.
5+
6+
poller
7+
======
8+
9+
Section configuring patch ingest.
10+
11+
recheck_period
12+
--------------
13+
14+
During normal operation poller fetches only the new patches - patches which
15+
were sent since the previous check (minus 10 minutes to account for email lag).
16+
17+
To catch patches which got stuck in the email systems for longer, or got sent with
18+
a date in the past poller will periodically scan patchwork looking back further into
19+
the past.
20+
21+
``recheck_period`` defines the period of the long scans in hours.
22+
23+
recheck_lookback
24+
----------------
25+
26+
Defines the length of the long history scan, see ``recheck_period``.

pw_poller.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def __init__(self) -> None:
7878
self.seen_series = set(self._state['done_series'])
7979
self.done_series = self.seen_series.copy()
8080

81+
self._recheck_period = config.getint('poller', 'recheck_period', fallback=3)
82+
self._recheck_lookback = config.getint('poller', 'recheck_lookback', fallback=9)
83+
8184
def init_state_from_disk(self) -> None:
8285
try:
8386
with open('poller.state', 'r') as f:
@@ -200,9 +203,9 @@ def run(self) -> None:
200203
req_time = datetime.datetime.utcnow()
201204

202205
# Decide if this is a normal 4 minute history poll or big scan of last 12 hours
203-
if prev_big_scan + datetime.timedelta(hours=3) < req_time:
206+
if prev_big_scan + datetime.timedelta(hours=self._recheck_period) < req_time:
204207
big_scan = True
205-
since = prev_big_scan - datetime.timedelta(hours=9)
208+
since = prev_big_scan - datetime.timedelta(hours=self._recheck_lookback)
206209
log_open_sec(f"Big scan of last 12 hours at {req_time} since {since}")
207210
else:
208211
big_scan = False

0 commit comments

Comments
 (0)