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(project-release): POST should not call Snuba #69831

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/sentry/api/endpoints/project_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ def post(self, request: Request, project) -> Response:

# Disable snuba here as it often causes 429s when overloaded and
# a freshly created release won't have health data anyways.
return Response(serialize(release, request.user, no_snuba=True), status=status)
return Response(
serialize(release, request.user, no_snuba_for_release_creation=True),
status=status,
)
scope.set_tag("failure_reason", "serializer_error")
return Response(serializer.errors, status=400)
24 changes: 14 additions & 10 deletions src/sentry/api/serializers/models/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def __get_project_id_list(self, item_list):
False,
)

def __get_release_data_no_environment(self, project, item_list):
def __get_release_data_no_environment(self, project, item_list, no_snuba_for_release_creation):
if project is not None:
project_ids = [project.id]
specialized = True
Expand All @@ -325,12 +325,16 @@ def __get_release_data_no_environment(self, project, item_list):

first_seen: dict[str, datetime.datetime] = {}
last_seen: dict[str, datetime.datetime] = {}
tag_values = tagstore.backend.get_release_tags(
organization_id,
project_ids,
environment_id=None,
versions=[o.version for o in item_list],
)
if no_snuba_for_release_creation:
Copy link
Member

Choose a reason for hiding this comment

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

question: why is snuba being called in a serializer? It doesn't make sense to me to have something that is supposed to serialize data make IO calls

Copy link
Member

Choose a reason for hiding this comment

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

^ good point 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave that decision to someone who has more context on release and merge this fix. @nhsiehgit would rotation backlog would be the right place to put this refactory ticket?

tag_values = []
else:
tag_values = tagstore.backend.get_release_tags(
organization_id,
project_ids,
environment_id=None,
versions=[o.version for o in item_list],
)

for tv in tag_values:
first_val = first_seen.get(tv.value)
last_val = last_seen.get(tv.value)
Expand Down Expand Up @@ -416,8 +420,8 @@ def get_attrs(self, item_list, user, **kwargs):
health_stat = kwargs.get("health_stat", None)
health_stats_period = kwargs.get("health_stats_period")
summary_stats_period = kwargs.get("summary_stats_period")
no_snuba = kwargs.get("no_snuba")
if with_health_data and no_snuba:
no_snuba_for_release_creation = kwargs.get("no_snuba_for_release_creation")
if with_health_data and no_snuba_for_release_creation:
raise TypeError("health data requires snuba")

adoption_stages = {}
Expand All @@ -428,7 +432,7 @@ def get_attrs(self, item_list, user, **kwargs):

if environments is None:
sentaur-athena marked this conversation as resolved.
Show resolved Hide resolved
first_seen, last_seen, issue_counts_by_release = self.__get_release_data_no_environment(
project, item_list
project, item_list, no_snuba_for_release_creation
)
else:
if release_project_envs is None:
Expand Down