-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
[CapMan visibility] surface CapMan summary in case of AllocationPolicyViolations #6052
Conversation
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.
There seems to be work done here to have two concepts (QuotaAllowance and Summary) in one dictionary. Why not have them be separate attributes?
I originally wanted to abstract away the fact that summary is an addition to quota allowances, since the intention is that any time quota allowances is retrieved, a summary should come with it. I updated pr to be your approach since I believe it's cleaner and easier to understand |
@@ -170,16 +170,25 @@ def quota_allowance(self) -> dict[str, dict[str, Any]]: | |||
dict[str, dict[str, Any]], self.extra_data.get("quota_allowances", {}) | |||
) | |||
|
|||
@property | |||
def summary(self) -> dict[str, Any]: | |||
return cast(dict[str, Any], self.extra_data.get("summary")) |
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.
Is there a case where the summary
key won't be in the extra_data
? If so, I don't think this typing holds true. In that case the function will return 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.
No, there will always be a summary
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 added an assertion
2e0f2cf
to
c7dbfd5
Compare
c7dbfd5
to
574a23a
Compare
snuba/web/views.py
Outdated
@@ -418,7 +418,8 @@ def dataset_query( | |||
{ | |||
"error": details, | |||
"timing": timer.for_json(), | |||
"quota_allowance": getattr(cause, "quota_allowance", {}), | |||
"quota_allowance": getattr(cause, "quota_allowance", {}) | |||
| getattr(cause, "summary", {}), |
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.
@evanh I initially had the two concepts in one dictionary because I was trying to avoid this. By previous design the summary field is a part of the quota_allowance dictionary, so if we kept them as separate attributes inside AllocationPolicyViolations, we have to re-combine them outside like this. I feel like this then becomes inconsistent with cases where the query is successful, and the quota_allowance
dictionary contains the summary field
6e59e53
to
f491fa6
Compare
Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time. ❌ Failed Test Results:Completed 2467 tests with View the full list of failed testspytest
|
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.
just some small changes but otherwise looks good
@@ -158,28 +158,33 @@ class AllocationPolicyViolations(SerializableException): | |||
""" | |||
|
|||
def __str__(self) -> str: | |||
return f"{self.message}, details: {self.violations}" | |||
return f"{self.message}, info: {self.violations | self.summary}" |
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.
return f"{self.message}, info: {self.violations | self.summary}" | |
return f"{self.message}, info: {"violations" self.violations, "summary": self.summary}" |
summary = self.quota_allowance.get("summary") | ||
assert summary is not None | ||
return {"summary": summary} |
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.
summary = self.quota_allowance.get("summary") | |
assert summary is not None | |
return {"summary": summary} | |
return self.quota_allowance.get("summary", {}) |
f491fa6
to
72675b4
Compare
https://getsentry.atlassian.net/browse/SNS-2798
Allocation policies are our mechanism for doing traffic management for Snuba queries. On Sentry issues webpage, the metadata regarding allocation policies are not surfaced.
In this PR, we relay the metadata to Sentry issues webpage so that they are displayed in that same section.