Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crons): Properly update monitorenvs in mark_ok with thresholds #57955

Merged
merged 9 commits into from
Oct 19, 2023

Conversation

rjo100
Copy link
Contributor

@rjo100 rjo100 commented Oct 11, 2023

Properly updates next/last checkin timestamps in mark_ok if threshold is enabled (but isn't met)

Fixes #57730

evanpurkhiser and others added 2 commits October 11, 2023 16:07
Previously when incidents were enabled (a recovery threshold was set) a
monitor would not have it's `next_checkin` or `next_checkin_latest`
updated until it recovered.
@rjo100 rjo100 requested a review from a team as a code owner October 11, 2023 23:50
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 11, 2023
and monitor_env.status != MonitorStatus.OK
):
params["status"] = MonitorStatus.OK
recovery_threshold = monitor_env.monitor.config.get("recovery_threshold", 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should just drop this confuging 0 default, it can be

  1. set and is enforced (by the validator) to be above zero
  2. set to None when the user does not specify the field
  3. not set, for old monitors

We should just leave the default blank and let it always be None

Comment on lines 38 to 40
previous_checkins = MonitorCheckIn.objects.filter(
monitor_environment=monitor_env
).order_by("-date_added")[:recovery_threshold]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does make me think @rjo100 we NEED a maximum value here. Do we have one?

Copy link
Contributor Author

@rjo100 rjo100 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can put a max in a diff PR on the validator and then we can reference that value and do a min(recovery_threshold, max_value)

...maybe 10? and then if people ask we can increase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we definitely need to have it. Otherwise someone is going to slap a huge number in here and break our whole system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #57955 (6a0568e) into master (1694b0a) will increase coverage by 0.71%.
Report is 16 commits behind head on master.
The diff coverage is 81.81%.

@@            Coverage Diff             @@
##           master   #57955      +/-   ##
==========================================
+ Coverage   78.35%   79.07%   +0.71%     
==========================================
  Files        5138     5139       +1     
  Lines      223631   223825     +194     
  Branches    37650    37684      +34     
==========================================
+ Hits       175226   176979    +1753     
+ Misses      42703    41180    -1523     
+ Partials     5702     5666      -36     
Files Coverage Δ
src/sentry/monitors/logic/mark_ok.py 100.00% <100.00%> (+4.76%) ⬆️
src/sentry/search/events/constants.py 100.00% <ø> (ø)
...ntry/services/hybrid_cloud/organization/service.py 80.37% <100.00%> (+0.37%) ⬆️
src/sentry/testutils/cases.py 83.72% <ø> (ø)
static/app/components/timeSince.tsx 81.25% <ø> (ø)
...app/utils/profiling/flamegraph/flamegraphTheme.tsx 100.00% <ø> (ø)
...jectDetail/projectScoreCards/projectScoreCards.tsx 100.00% <ø> (ø)
static/app/views/projectDetail/utils.tsx 100.00% <100.00%> (ø)
static/app/views/replays/detail/page.tsx 0.00% <ø> (ø)
src/sentry/integrations/github/integration.py 83.75% <66.66%> (-0.35%) ⬇️
... and 5 more

... and 171 files with indirect coverage changes

@rjo100
Copy link
Contributor Author

rjo100 commented Oct 18, 2023

confirmed working in devserver

@rjo100 rjo100 merged commit cd31f22 into master Oct 19, 2023
50 of 51 checks passed
@rjo100 rjo100 deleted the rjo100/fix-mark-ok-timestamps branch October 19, 2023 17:56
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants