-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
chore(hybridcloud) Remove role switching and update guard method #52673
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7dc71bc
Continue replacing role switching with query auditing
markstory e296f85
Update guard method and update usage.
markstory 79c7106
Merge branch 'master' into chore-cleanup-query-audits
markstory 3aeffb8
Merge branch 'master' into chore-cleanup-query-audits
markstory db74be0
Merge branch 'master' into chore-cleanup-query-audits
markstory 574f54d
Restore all the role logic so that getsentry will pass.
markstory 273a9a5
Fix another failing test.
markstory f6ca765
Merge branch 'master' into chore-cleanup-query-audits
markstory a96e10e
Merge branch 'master' into chore-cleanup-query-audits
markstory 6ea7521
Merge branch 'master' into chore-cleanup-query-audits
markstory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
region_silo_only_model, | ||
sane_repr, | ||
) | ||
from sentry.db.postgres.roles import in_test_psql_role_override | ||
from sentry.silo import SiloMode | ||
|
||
|
||
|
@@ -94,6 +93,8 @@ def increment_project_counter(project, delta=1, using="default"): | |
# this must be idempotent because it seems to execute twice | ||
# (at least during test runs) | ||
def create_counter_function(app_config, using, **kwargs): | ||
from sentry.testutils.silo import unguarded_write | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Circular import sadness. |
||
|
||
if app_config and app_config.name != "sentry": | ||
return | ||
|
||
|
@@ -103,7 +104,7 @@ def create_counter_function(app_config, using, **kwargs): | |
if SiloMode.get_current_mode() == SiloMode.CONTROL: | ||
return | ||
|
||
with in_test_psql_role_override("postgres", using), connections[using].cursor() as cursor: | ||
with unguarded_write(using), connections[using].cursor() as cursor: | ||
cursor.execute( | ||
""" | ||
create or replace function sentry_increment_project_counter( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
from typing import Optional | ||
|
||
from sentry.models import AuditLogEntry, CommitFileChange | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More circular import sadness. |
||
|
||
|
||
def assert_mock_called_once_with_partial(mock, *args, **kwargs): | ||
""" | ||
|
@@ -16,10 +14,11 @@ def assert_mock_called_once_with_partial(mock, *args, **kwargs): | |
assert m_kwargs[kwarg] == kwargs[kwarg], (m_kwargs[kwarg], kwargs[kwarg]) | ||
|
||
|
||
commit_file_type_choices = {c[0] for c in CommitFileChange._meta.get_field("type").choices} | ||
def assert_commit_shape(commit): | ||
from sentry.models import CommitFileChange | ||
|
||
commit_file_type_choices = {c[0] for c in CommitFileChange._meta.get_field("type").choices} | ||
|
||
def assert_commit_shape(commit): | ||
assert commit["id"] | ||
assert commit["repository"] | ||
assert commit["author_email"] | ||
|
@@ -40,6 +39,8 @@ def assert_status_code(response, minimum: int, maximum: Optional[int] = None): | |
|
||
|
||
def org_audit_log_exists(**kwargs): | ||
from sentry.models import AuditLogEntry | ||
|
||
assert kwargs | ||
if "organization" in kwargs: | ||
kwargs["organization_id"] = kwargs.pop("organization").id | ||
|
@@ -55,4 +56,6 @@ def assert_org_audit_log_does_not_exist(**kwargs): | |
|
||
|
||
def delete_all_org_audit_logs(): | ||
from sentry.models import AuditLogEntry | ||
|
||
return AuditLogEntry.objects.all().delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 will be around for a bit longer until I can update getsentry.