diff --git a/bugbot/rules/perfalert_inactive_regression.py b/bugbot/rules/perfalert_inactive_regression.py index 72134ff33..599cb9023 100644 --- a/bugbot/rules/perfalert_inactive_regression.py +++ b/bugbot/rules/perfalert_inactive_regression.py @@ -4,6 +4,8 @@ import collections +import numpy +from libmozdata import utils as lmdutils from libmozdata.bugzilla import Bugzilla from bugbot import logger, utils @@ -12,14 +14,14 @@ class PerfAlertInactiveRegression(BzCleaner): - def __init__(self, nweeks=1): + def __init__(self, ndays=3): super().__init__() - self.nweeks = nweeks - self.extra_ni = {"nweeks": self.nweeks} + self.ndays = ndays + self.extra_ni = {"ndays": self.ndays} self.private_regressor_ids: set[str] = set() def description(self): - return f"PerfAlert regressions with {self.nweeks} week(s) of inactivity" + return f"PerfAlert regressions with {self.ndays} day(s) of inactivity" def handle_bug(self, bug, data): if len(bug["regressed_by"]) != 1: @@ -27,6 +29,16 @@ def handle_bug(self, bug, data): # or there's more than one, either way leave things alone return + # Skip bugs that haven't been inactive for enough business days + if ( + numpy.busday_count( + lmdutils.get_date_ymd(bug["last_change_time"]).date(), + lmdutils.get_date("today"), + ) + <= self.ndays + ): + return + data[str(bug["id"])] = { "regressor_id": bug["regressed_by"][0], } @@ -39,6 +51,7 @@ def get_bz_params(self, date): fields = [ "id", "regressed_by", + "last_change_time", ] # Find all bugs that have perf-alert, and regression in their keywords. Only @@ -58,8 +71,8 @@ def get_bz_params(self, date): "o4": "nowords", "v4": "backlog-deferred", "f5": "days_elapsed", - "o5": "greaterthan", - "v5": self.nweeks * 7, + "o5": "greaterthaneq", + "v5": self.ndays, "status": ["UNCONFIRMED", "NEW", "REOPENED"], "resolution": ["---"], } diff --git a/bugbot/rules/telemetryalert_inactive_regression.py b/bugbot/rules/telemetryalert_inactive_regression.py index 6c88659a7..78ed3be15 100644 --- a/bugbot/rules/telemetryalert_inactive_regression.py +++ b/bugbot/rules/telemetryalert_inactive_regression.py @@ -3,6 +3,8 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. +import numpy +from libmozdata import utils as lmdutils from libmozdata.bugzilla import BugzillaUser from bugbot.bzcleaner import BzCleaner @@ -10,13 +12,13 @@ class TelemetryAlertInactiveRegression(BzCleaner): - def __init__(self, nweeks=1): + def __init__(self, ndays=3): super().__init__() - self.nweeks = nweeks - self.extra_ni = {"nweeks": self.nweeks} + self.ndays = ndays + self.extra_ni = {"ndays": self.ndays} def description(self): - return f"Telemetry alerts with {self.nweeks} week(s) of inactivity" + return f"Telemetry alerts with {self.ndays} day(s) of inactivity" def get_extra_for_needinfo_template(self): return self.extra_ni @@ -30,10 +32,11 @@ def get_bz_params(self, date): fields = [ "id", "history", + "last_change_time", ] # Find all bugs that have a telemetry-alert keyword, have not changed in the - # last week, and do not have the backlog-deferred keyword set + # last few days, and do not have the backlog-deferred keyword set params = { "include_fields": fields, "f3": "keywords", @@ -43,8 +46,8 @@ def get_bz_params(self, date): "o4": "nowords", "v4": "backlog-deferred", "f5": "days_elapsed", - "o5": "greaterthan", - "v5": self.nweeks * 7, + "o5": "greaterthaneq", + "v5": self.ndays, "status": ["UNCONFIRMED", "NEW", "REOPENED"], "resolution": ["---"], } @@ -78,6 +81,16 @@ def get_probe_owner(self, bug_history): return probe_owner def handle_bug(self, bug, data): + # Skip bugs that haven't been inactive for enough business days + if ( + numpy.busday_count( + lmdutils.get_date_ymd(bug["last_change_time"]).date(), + lmdutils.get_date("today"), + ) + <= self.ndays + ): + return + probe_owner = self.get_probe_owner(bug["history"]) if not probe_owner: # Could not find a probe owner for some reason diff --git a/scripts/cron_run_daily.sh b/scripts/cron_run_daily.sh index 1b04ca639..ce39b7797 100755 --- a/scripts/cron_run_daily.sh +++ b/scripts/cron_run_daily.sh @@ -12,15 +12,9 @@ python -m bugbot.rules.accessibilitybug --production # Try to detect potential performance-related bugs using bugbug python -m bugbot.rules.performancebug --production -# Try to detect potential performance alerts that have been inactive for too long -python -m bugbot.rules.perfalert_inactive_regression --production - # Send an email about all performance alerts who were recently resolved python -m bugbot.rules.perfalert_resolved_regression --production -# Try to detect potential telemetry alerts that have been inactive for too long -python -m bugbot.rules.telemetryalert_inactive_regression --production - # Update the webcompat score fields python -m bugbot.rules.webcompat_score --production diff --git a/scripts/cron_run_weekdays.sh b/scripts/cron_run_weekdays.sh index 6b0e7a446..1cb443410 100755 --- a/scripts/cron_run_weekdays.sh +++ b/scripts/cron_run_weekdays.sh @@ -202,4 +202,10 @@ python -m bugbot.rules.severity_high_performance_impact --production # Request potential missing info when a bug is moved to Core::Performance python -m bugbot.rules.moved_to_performance --production +# Try to detect potential performance alerts that have been inactive for too long +python -m bugbot.rules.perfalert_inactive_regression --production + +# Try to detect potential telemetry alerts that have been inactive for too long +python -m bugbot.rules.telemetryalert_inactive_regression --production + source ./scripts/cron_common_end.sh diff --git a/templates/perfalert_inactive_regression.html b/templates/perfalert_inactive_regression.html index 3cef30843..91c3e3ed6 100644 --- a/templates/perfalert_inactive_regression.html +++ b/templates/perfalert_inactive_regression.html @@ -1,5 +1,5 @@

- The following {{ plural('bug is a performance alert which has had', data, pword='bugs are performance alerts which have had') }} no activity in the last {{ extra['nweeks'] * 7 }} days: + The following {{ plural('bug is a performance alert which has had', data, pword='bugs are performance alerts which have had') }} no activity in the last {{ extra['ndays'] }} days:

diff --git a/templates/perfalert_inactive_regression_needinfo.txt b/templates/perfalert_inactive_regression_needinfo.txt index 9cdcc5f78..16e5c0b62 100644 --- a/templates/perfalert_inactive_regression_needinfo.txt +++ b/templates/perfalert_inactive_regression_needinfo.txt @@ -1,9 +1,11 @@ -It has been over {{ extra["nweeks"] * 7 }} days with no activity on this performance regression. +It has been over {{ extra["ndays"] }} days with no activity on this performance regression. :{{ nickname }}, since you are the author of the regressor, bug {{ extra[bugid]["regressor_id"] }}, which triggered this performance alert, could you please provide a progress update? If this regression is something that fixes a bug, changes the baseline of the regression metrics, or otherwise will not be fixed, please consider closing it as WONTFIX. [See this documentation for more information on how to handle regressions](https://firefox-source-docs.mozilla.org/testing/perfdocs/perftest-in-a-nutshell.html#help-i-have-a-regression-what-do-i-do). +If it’s unclear when the alert may be resolved, then it’s recommended to file a follow-up bug, and close the alert as INCOMPLETE. + For additional information/help, please needinfo the performance sheriff who filed this alert (they can be found in comment #0), or reach out in [#perftest](https://matrix.to/#/#perftest:mozilla.org), or [#perfsheriffs](https://matrix.to/#/#perfsheriffs:mozilla.org) on Element. {{ documentation }} diff --git a/templates/telemetryalert_inactive_regression.html b/templates/telemetryalert_inactive_regression.html index c8529957b..bbda85e9e 100644 --- a/templates/telemetryalert_inactive_regression.html +++ b/templates/telemetryalert_inactive_regression.html @@ -1,5 +1,5 @@

- The following {{ plural('bug is a telemetry alert which has had', data, pword='bugs are telemetry alerts which have had') }} no activity in the last {{ extra['nweeks'] * 7 }} days: + The following {{ plural('bug is a telemetry alert which has had', data, pword='bugs are telemetry alerts which have had') }} no activity in the last {{ extra['ndays'] }} days:

diff --git a/templates/telemetryalert_inactive_regression_needinfo.txt b/templates/telemetryalert_inactive_regression_needinfo.txt index 2c7cd0b5d..4f94f73a1 100644 --- a/templates/telemetryalert_inactive_regression_needinfo.txt +++ b/templates/telemetryalert_inactive_regression_needinfo.txt @@ -1,7 +1,9 @@ -It has been over {{ extra["nweeks"] * 7 }} days with no activity on this telemetry alert. +It has been over {{ extra["ndays"] }} days with no activity on this telemetry alert. :{{ nickname }}, since you are the owner of the probe that alerted, could you please provide a progress update? If there are any questions about how to proceed for finding a culprit please check comment #0 for information on how to find help. +If it’s unclear when the alert may be resolved, then it’s recommended to file a follow-up bug, and close the alert as INCOMPLETE. + {{ documentation }}