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

feat(hybridcloud) Use control file for user/sentryapp avatars #54118

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

markstory
Copy link
Member

Going forward always write to ControlFile for User & sentry app avatars. This helps make application logic more consistent going forwards as new avatars are always stored in ControlFile.

I've retained read paths for File backed avatars so that we preserve behavior in both single-tenant and self-hosted. We also retain the ability to write to a control silo specific storage bucket should an environment be configured in that way.

I'd like to phase out the storage rebuild task as we're not planning on doing it in any of the non-saas environments and self-hosted multi-region sentry isn't something we're planning on supporting either.

Going forward always write to ControlFile for User & sentry app avatars.
This helps make application logic more consistent going forwards as
new avatars are always stored in ControlFile. I've retained read paths
for `File` backed avatars so that we preserve behavior in both
single-tenant and self-hosted. We also retain the ability to write to
a control silo specific storage bucket should an environment be
configured in that way.
@markstory markstory requested a review from a team August 3, 2023 19:25
@markstory markstory requested a review from a team as a code owner August 3, 2023 19:25
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 3, 2023
@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Merging #54118 (69ba210) into master (e46ca23) will increase coverage by 0.00%.
Report is 7 commits behind head on master.
The diff coverage is 92.85%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #54118   +/-   ##
=======================================
  Coverage   79.65%   79.66%           
=======================================
  Files        4989     4989           
  Lines      211491   211509   +18     
  Branches    36048    36051    +3     
=======================================
+ Hits       168471   168503   +32     
+ Misses      37834    37825    -9     
+ Partials     5186     5181    -5     
Files Changed Coverage Δ
src/sentry/monitors/consumers/monitor_consumer.py 88.88% <ø> (-0.05%) ⬇️
static/app/components/datePageFilter.tsx 94.44% <ø> (-0.30%) ⬇️
...mponents/organizations/pageFilters/persistence.tsx 70.96% <ø> (-0.91%) ⬇️
...mponents/organizations/timeRangeSelector/index.tsx 89.38% <ø> (ø)
static/app/views/issueDetails/groupDetails.tsx 66.66% <ø> (ø)
src/sentry/models/files/control_fileblob.py 85.18% <71.42%> (-2.32%) ⬇️
src/sentry/tasks/files.py 80.64% <85.71%> (+3.22%) ⬆️
...entry/api/endpoints/organization_member/details.py 88.57% <100.00%> (ø)
...api/serializers/models/organization_member/base.py 98.41% <100.00%> (+0.07%) ⬆️
src/sentry/models/avatars/base.py 78.21% <100.00%> (+1.21%) ⬆️
... and 3 more

... and 4 files with indirect coverage changes

src/sentry/models/avatars/base.py Show resolved Hide resolved
src/sentry/models/avatars/base.py Show resolved Hide resolved
Comment on lines -22 to +32
if ControlFileBlob._storage_config():
def file_fk(self) -> str:
if self.control_file_id:
return "control_file_id"
return "file_id"
if self.file_id:
return "file_id"
return "control_file_id"
Copy link
Member

Choose a reason for hiding this comment

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

This behavior may be a bit problematic in split DB test contexts, since accessing the normal file_id in a fallback case will likely result in a cross-DB access in some transaction contexts (see test_doc_integration_avatar.py for example). Are we sure we don't want to just default to control_file_id at this 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.

Non-saas environments never moved useravatar or sentryapp avatars to control file (as they don't have the separate bucket config). We need to continue using file_id for those environments as that is where their files are.

I'm considering following up this change with a backfill migration that copies all the file/fileblob/fileblobindex records for user & sentryapp avatars into ControlFile. If we do that backfill then all environments will become consistent and we can simplify this code as we don't need to split reads anymore.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh I didn't realize we hadn't backfilled the non-saas deploys 😞 Yeah that makes sense. Should we maybe do an env check for split db mode and fail fast in that scenario just to ensure we don't keep around these cross-db accesses?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah a split db check could work too. I'd like to get rid of the cross-db reads, but how to get there is the part I'm still trying to figure out. Migrations only have access to historical models which don't have the methods we need to move file records between backends. We could spawn the copy file task, but we'll need to account for the task changing signature/going missing in the future.

@markstory markstory merged commit 25d04ff into master Aug 9, 2023
56 checks passed
@markstory markstory deleted the feat-avatar-dual-read branch August 9, 2023 13:58
@markstory markstory added the Trigger: Revert add to a merged PR to revert it (skips CI) label Aug 9, 2023
@getsentry-bot
Copy link
Contributor

PR reverted: 4e10fc3

getsentry-bot added a commit that referenced this pull request Aug 9, 2023
…#54118)"

This reverts commit 25d04ff.

Co-authored-by: markstory <24086+markstory@users.noreply.github.com>
markstory added a commit that referenced this pull request Aug 9, 2023
Mulligan on #54118. The first merge of this failed as the new logic is
incompatible with a test in getsentry.

This reverts commit 4e10fc3.
markstory added a commit that referenced this pull request Aug 9, 2023
)

Mulligan on #54118. The first merge of this failed as the new logic is
incompatible with a test in getsentry.

This reverts commit 4e10fc3.

Requires getsentry/getsentry#11392
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2023
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 Trigger: Revert add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants