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): Initial removal of status from Monitor object #47910

Merged
merged 9 commits into from
Apr 27, 2023

Conversation

rjo100
Copy link
Contributor

@rjo100 rjo100 commented Apr 25, 2023

Removes references as best as possible to next_checkin, last_checkin, and status (where appropriate) on the Monitor object.

Will require follow up work to remove hacks/TODOs as well as actually migrate the database and potentially backfill where appropriate.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 25, 2023
@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Merging #47910 (5d07a29) into master (07ce59e) will decrease coverage by 0.01%.
The diff coverage is 87.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #47910      +/-   ##
==========================================
- Coverage   80.86%   80.86%   -0.01%     
==========================================
  Files        4769     4769              
  Lines      201565   201543      -22     
  Branches    11557    11557              
==========================================
- Hits       162990   162970      -20     
+ Misses      38319    38317       -2     
  Partials      256      256              
Impacted Files Coverage Δ
src/sentry/monitors/consumers/check_in.py 87.50% <ø> (-0.28%) ⬇️
...rs/endpoints/organization_monitor_checkin_index.py 94.73% <ø> (ø)
src/sentry/monitors/serializers.py 100.00% <ø> (ø)
src/sentry/monitors/tasks.py 97.14% <ø> (-0.16%) ⬇️
src/sentry/monitors/models.py 95.58% <83.33%> (-0.25%) ⬇️
...nitors/endpoints/monitor_ingest_checkin_details.py 86.00% <100.00%> (-6.31%) ⬇️
...monitors/endpoints/monitor_ingest_checkin_index.py 95.83% <100.00%> (-0.12%) ⬇️

... and 4 files with indirect coverage changes

@rjo100 rjo100 marked this pull request as ready for review April 25, 2023 19:32
@rjo100 rjo100 requested a review from a team as a code owner April 25, 2023 19:32
@@ -111,6 +112,8 @@ def put(self, request: Request, organization, project, monitor) -> Response:

if params:
monitor.update(**params)
if params.get("status"):
MonitorEnvironment.objects.filter(monitor=monitor).update(status=params["status"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will fix a sort bug by marking the MonitorEnvironment as DISABLED

Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we want this? I would think we would just want to keep the sorting logic so that monitors that are disabled get sorted to the bottom and just ignore the disabled in that case.

I would also probably not do this in this cleanup PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue is that we only read off the MonitorEnvironment status during sort right now, and that never gets marked as DISABLED. this is the only place we have that hook. some of this follow up work was going to simplify the sort logic but really it's more pending the "one row per monitor w/multiple environments" UI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#48039
fix is here. will remove this

Copy link
Member

Choose a reason for hiding this comment

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

Good stuff 👍

@@ -99,6 +99,7 @@ def put(self, request: Request, organization, project, monitor) -> Response:
if "slug" in result:
params["slug"] = result["slug"]
if "status" in result:
# TODO(rjo100): resets status if monitor is failed, needs fixing with environments
if result["status"] == MonitorStatus.ACTIVE:
Copy link
Member

Choose a reason for hiding this comment

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

We're going to do a migration here to move all monitors that are in non ObjectStatus type status to ACTIVE or DISABLED right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally yes. we reference PENDING DELETION a lot too

Copy link
Member

Choose a reason for hiding this comment

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

that's OK, pending deletion is part of ObjectStatus right

@@ -218,43 +218,6 @@ def get_next_scheduled_checkin(self, last_checkin):
)
return next_checkin + timedelta(minutes=int(self.config.get("checkin_margin") or 0))

def mark_failed(self, last_checkin=None, reason=MonitorFailure.UNKNOWN):
Copy link
Member

Choose a reason for hiding this comment

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

nice

@@ -86,8 +86,6 @@ def serialize(self, obj, attrs, user):
"name": obj.name,
"slug": obj.slug,
"config": config,
"lastCheckIn": obj.last_checkin,
"nextCheckIn": obj.next_checkin,
Copy link
Member

Choose a reason for hiding this comment

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

very nice

def get_status_display(self) -> str:
for status_id, display in MonitorStatus.as_choices():
if status_id in [
ObjectStatus.ACTIVE,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know this is duplicate but I'd rather keep it for readability sake

@rjo100 rjo100 enabled auto-merge (squash) April 27, 2023 02:17
@rjo100 rjo100 merged commit 87ad96a into master Apr 27, 2023
@rjo100 rjo100 deleted the rjo100/remove-monitor-status-backend branch April 27, 2023 02:43
@github-actions github-actions bot locked and limited conversation to collaborators May 12, 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.

2 participants