Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 020c354

Browse files
Merge pull request #241 from ocf/no-more-rebuild-spam
Reduce #rebuild spam
2 parents 34a0917 + ce5921b commit 020c354

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ircbot/plugin/debian_security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def dsa_list():
16-
req = requests.get('https://www.debian.org/security/dsa-long')
16+
req = requests.get('https://www.debian.org/security/dsa-long', timeout=30)
1717
req.raise_for_status()
1818

1919
root = ElementTree.fromstring(req.content)

ircbot/plugin/timer.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
from ircbot.plugin import debian_security
88

99
# Check for Debian security announcements every 5 minutes
10-
# If a check fails, we bump add another 5 minutes, until
11-
# the maximum of 30 minutes
10+
# If a check fails, we bump add another 10 minutes, until
11+
# the maximum of 120 minutes
1212
DSA_FREQ_DEFAULT = 5
13-
DSA_FREQ_BACKOFF = 5
14-
DSA_FREQ_MAX = 30
13+
DSA_FREQ_BACKOFF = 10
14+
DSA_FREQ_MAX = 120
1515

1616

1717
def register(bot):
1818
bot.add_thread(timer)
1919

2020

2121
def timer(bot):
22+
exception_count = 0
2223
dsa_freq = DSA_FREQ_DEFAULT
2324

2425
last_date = None
@@ -39,11 +40,15 @@ def timer(bot):
3940
for line in debian_security.get_new_dsas():
4041
bot.say('#rebuild', line)
4142

43+
# After a successful fetch, reset the exception count
44+
exception_count = 0
4245
# After a successful fetch, we reset timer to 5m
4346
dsa_freq = DSA_FREQ_DEFAULT
4447
except Exception as ex:
45-
error_msg = f'ircbot exception in timer: {ex}'
46-
bot.say('#rebuild', error_msg)
48+
exception_count += 1
49+
error_msg = f'ircbot exception in timer: {ex}, this error occurred {exception_count} times.'
50+
if exception_count > 9:
51+
bot.say('#rebuild', error_msg)
4752
bot.handle_error(
4853
dedent(
4954
"""

0 commit comments

Comments
 (0)