-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(releases): For semver releases, get latest release as the resolving one #80737
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #80737 +/- ##
========================================
Coverage 78.39% 78.39%
========================================
Files 7206 7206
Lines 319290 319437 +147
Branches 43977 43991 +14
========================================
+ Hits 250306 250434 +128
- Misses 62607 62618 +11
- Partials 6377 6385 +8 |
def get_current_release_version_of_group( | ||
group: Group, follows_semver: bool = False | ||
) -> Release | None: | ||
def get_current_release_version_of_group(group: Group, follows_semver: bool = False) -> str | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add stronger typing enforcement here. It returns a string.
@@ -140,13 +138,12 @@ def get_current_release_version_of_group( | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes in this block besides some minor refactoring to help comprehension.
"organizations:releases-resolve-next-release-semver-fix", | ||
project.organization, | ||
): | ||
resolving_release_version = get_latest_release(projects[0]).version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix.
src/sentry/testutils/fixtures.py
Outdated
if project is None: | ||
project = self.project | ||
if "substatus" not in kwargs: | ||
kwargs["substatus"] = GroupSubStatus.NEW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor improvement. You could see a logged error when this is not set.
@@ -328,7 +328,11 @@ def test_resolved_in_next_release_non_semver(self): | |||
project = self.create_project() | |||
project.flags.has_releases = True | |||
project.save() | |||
group = self.create_group(project=project) | |||
# Using store_event() instead of create_group() produces GroupRelease objects | |||
# which is considered during the update_groups() call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change helps the test go through the ingestion pipeline, thus, creating GroupRelease objects.
Entrypoint:
sentry/src/sentry/event_manager.py
Line 509 in 3ae2f67
_get_or_create_release_many(jobs, projects) |
Where is used:
sentry/src/sentry/api/helpers/group_index/update.py
Lines 125 to 149 in 3ae2f67
def get_current_release_version_of_group( | |
group: Group, follows_semver: bool = False | |
) -> Release | None: | |
""" | |
Function that returns the latest release version associated with a Group, and by latest we | |
mean either most recent (date) or latest in semver versioning scheme | |
Inputs: | |
* group: Group of the issue | |
* follows_semver: flag that determines whether the project of the group follows semantic | |
versioning or not. | |
Returns: | |
current_release_version | |
""" | |
current_release_version = None | |
if follows_semver: | |
try: | |
# This sets current_release_version to the latest semver version associated with a group | |
order_by_semver_desc = [f"-{col}" for col in Release.SEMVER_COLS] | |
current_release_version = ( | |
Release.objects.filter_to_semver() | |
.filter( | |
id__in=GroupRelease.objects.filter( | |
project_id=group.project.id, group_id=group.id | |
).values_list("release_id"), | |
) |
# For semver projects, we consider resolution based on an expression rather than a specific release, | ||
# thus, it is considered resolved in the release that has the highest semver | ||
assert group_resolution.type == GroupResolution.Type.in_release | ||
assert group_resolution.status == GroupResolution.Status.resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is evidence that we're going through the same code path as reported by Dropbox.
sentry/src/sentry/api/helpers/group_index/update.py
Lines 440 to 449 in 3ae2f67
# In semver projects, and thereby semver releases, we determine | |
# resolutions by comparing against an expression rather than a | |
# specific release (i.e. >current_release_version). Consequently, | |
# at this point we can consider this GroupResolution as resolved | |
# in release | |
resolution_params.update( | |
{ | |
"type": GroupResolution.Type.in_release, | |
"status": GroupResolution.Status.resolved, | |
} |
@@ -351,17 +355,22 @@ def test_resolved_in_next_release_non_semver(self): | |||
assert group_resolution.release.version == most_recent_version.version | |||
|
|||
# XXX: Remove this test once the feature flag is removed | |||
def test_resolved_in_next_release_semver_without_feature_flag(self): | |||
def test_resolved_in_next_release_semver_no_flag_and_first_release(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have added one more test (one without setting the release), however, we're moving away from this logic, thus, I do not deem it necessary.
) | ||
and follows_semver | ||
): | ||
current_release_version = get_latest_release(projects[0]).version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix.
new_release = Release.get_or_create(version="[email protected]+0", project=project) | ||
# A lesser release than 2.x but created more recently than 3.x | ||
old_version = Release.get_or_create(version="[email protected]+0", project=project) | ||
for release in releases + [old_version]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix, only [email protected]+0
would not unresolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@@ -419,9 +416,19 @@ def update_groups( | |||
release_version=release.version, | |||
) | |||
|
|||
current_release_version = get_current_release_version_of_group( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should look to remove this as a follow-up
sentry/src/sentry/integrations/tasks/sync_status_inbound.py
Lines 112 to 114 in c079722
current_release_version = get_current_release_version_of_group( | |
group=group, follows_semver=follows_semver | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed-up here: #80821
In #80737 we provided a fix within `get_latest_release()` but it makes more sense to include inside of `get_current_release_version_of_group()` for it will make it available to other parts of the codebase. For example: https://github.com/getsentry/sentry/blob/c0797226ec0dc304d766796713121a880df38811/src/sentry/integrations/tasks/sync_status_inbound.py#L112-L114
In #80737 we provided a fix within `get_latest_release()` but it makes more sense to include inside of `get_current_release_version_of_group()` for it will make it available to other parts of the codebase. For example: https://github.com/getsentry/sentry/blob/c0797226ec0dc304d766796713121a880df38811/src/sentry/integrations/tasks/sync_status_inbound.py#L112-L114
…p() (#80821) In #80737 we provided a fix within `get_latest_release()` but it makes more sense to include it inside of `get_current_release_version_of_group()` for it will make it available to other parts of the codebase. For example: https://github.com/getsentry/sentry/blob/c0797226ec0dc304d766796713121a880df38811/src/sentry/integrations/tasks/sync_status_inbound.py#L112-L114
I will enable this for GA next week. |
Select the latest semver release for the project rather than the latest seen for the group.
This is a follow-up to #80655.
This fixes the customer issue #69937 (and possibly these: #74448 and #80194).