Skip to content

chore(control_silo): Move User model to new home in users package #75597

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

Merged
merged 20 commits into from
Aug 13, 2024

Conversation

Christinarlong
Copy link
Contributor

Part of consolidating (user) control silo resources to be located with other user related models.

Ref(#73856)

Moves the User model to new home in sentry/users/models/ and tests to tests/sentry/users/models

ref(issue # here)
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 5, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a lot of return & parameter typing for this file, pls double check if the types are wrong. I'll point out some specific ones I'm unsure on

# sessions and refresh their nonce.
@receiver(user_logged_out, sender=User)
def refresh_user_nonce(
sender: User | RpcUser, request: HttpRequest, user: User | None, **kwargs: Any
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unsure if request can be None too ?

Copy link
Member

Choose a reason for hiding this comment

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

All of the current callers provide the request, but signals make no promises on providing all of their parameters. Annotating this as HttpRequest | None seems wise.

Copy link

codecov bot commented Aug 6, 2024

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 21745 tests with 1 failed, 21543 passed and 201 skipped.

View the full list of failed tests

pytest

  • Class name: tests.sentry.hybridcloud.tasks.test_backfill_outboxes
    Test name: test_control_processing[CONTROL]
    Flags:
    • backend

    #x1B[1m#x1B[.../hybridcloud/tasks/test_backfill_outboxes.py#x1B[0m:159: in test_control_processing
    assert get_processing_state(AuthIdentity._meta.db_table)[1] == 10001
    #x1B[1m#x1B[31mE assert 10000 == 10001#x1B[0m

batch.count shouldn't be able to go negative. This can happen when
a batch is complete, and has no additional data so low=`max id` and
up=0. This edge case came up in testing as our batch sizes are 1, and
other tests created enough rows to cause the sequence state to get high
enough that the incorrect batch.count resulted in backfills aborting
early.

I've also added a `__str__` to make future debugging easier.
@Christinarlong Christinarlong marked this pull request as ready for review August 13, 2024 17:41
@Christinarlong Christinarlong requested review from a team as code owners August 13, 2024 17:41
@Christinarlong Christinarlong requested a review from a team August 13, 2024 17:41
@Christinarlong Christinarlong requested review from a team as code owners August 13, 2024 17:41
@Christinarlong Christinarlong requested review from AbhiPrasad and s1gr1d and removed request for a team August 13, 2024 17:41
Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Looks good to me. Most of the changes are import updates. I didn't spot any logic differences in the User model.

# sessions and refresh their nonce.
@receiver(user_logged_out, sender=User)
def refresh_user_nonce(
sender: User | RpcUser, request: HttpRequest, user: User | None, **kwargs: Any
Copy link
Member

Choose a reason for hiding this comment

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

All of the current callers provide the request, but signals make no promises on providing all of their parameters. Annotating this as HttpRequest | None seems wise.

Comment on lines 597 to 598
def refresh_api_user_nonce(
sender: RpcUser, request: HttpRequest, user: User | None, **kwargs: Any
Copy link
Member

Choose a reason for hiding this comment

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

Same here, I would assume that all parameters could be None.

@Christinarlong Christinarlong merged commit e892643 into master Aug 13, 2024
48 checks passed
@Christinarlong Christinarlong deleted the christinarlong/consolidate-users-models-user branch August 13, 2024 20:00
Copy link

sentry-io bot commented Aug 13, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:... pytest.runtest.protocol tests/sentry/tasks/test... View Issue
  • ‼️ IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:... pytest.runtest.protocol tests/sentry/api/endpoi... View Issue
  • ‼️ IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:... pytest.runtest.protocol tests/sentry/integratio... View Issue
  • ‼️ IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:... pytest.runtest.protocol tests/sentry/api/endpoi... View Issue
  • ‼️ IntegrityError: UniqueViolation('duplicate key value violates unique constraint "auth_user_username_key"\nDETAIL:... pytest.runtest.protocol tests/sentry/api/endpoi... View Issue

Did you find this useful? React with a 👍 or 👎

ameliahsu pushed a commit that referenced this pull request Aug 13, 2024
…5597)

Part of consolidating (user) control silo resources to be located with other user related models. Leaves behind a shim for any getsentry references. Also includes a fix for backfill_outboxes to ensure batch.count doesn't become negative which caused tests in test_backfill_outboxes to fail.

Ref(#73856)

---------

Co-authored-by: Mark Story <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2024
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