Skip to content

Commit 68ae3ce

Browse files
authored
chore(hybridcloud) Remove file_id from control avatar subclasses (#68916)
Control silo scoped avatars don't need a file_id column as they use control_file_id instead. Refs HC-712 Requires getsentry/getsentry#13659
1 parent aedfc9d commit 68ae3ce

File tree

9 files changed

+52
-66
lines changed

9 files changed

+52
-66
lines changed

fixtures/backup/model_dependencies/detailed.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,11 +1748,6 @@
17481748
"kind": "FlexibleForeignKey",
17491749
"model": "sentry.docintegration",
17501750
"nullable": false
1751-
},
1752-
"file_id": {
1753-
"kind": "ImplicitForeignKey",
1754-
"model": "sentry.file",
1755-
"nullable": true
17561751
}
17571752
},
17581753
"model": "sentry.docintegrationavatar",
@@ -1766,9 +1761,6 @@
17661761
[
17671762
"control_file_id"
17681763
],
1769-
[
1770-
"file_id"
1771-
],
17721764
[
17731765
"ident"
17741766
]
@@ -5538,11 +5530,6 @@
55385530
"model": "sentry.controlfile",
55395531
"nullable": true
55405532
},
5541-
"file_id": {
5542-
"kind": "ImplicitForeignKey",
5543-
"model": "sentry.file",
5544-
"nullable": true
5545-
},
55465533
"sentry_app": {
55475534
"kind": "FlexibleForeignKey",
55485535
"model": "sentry.sentryapp",
@@ -5560,9 +5547,6 @@
55605547
[
55615548
"control_file_id"
55625549
],
5563-
[
5564-
"file_id"
5565-
],
55665550
[
55675551
"ident"
55685552
]
@@ -5986,11 +5970,6 @@
59865970
"model": "sentry.controlfile",
59875971
"nullable": true
59885972
},
5989-
"file_id": {
5990-
"kind": "ImplicitForeignKey",
5991-
"model": "sentry.file",
5992-
"nullable": true
5993-
},
59945973
"user": {
59955974
"kind": "FlexibleForeignKey",
59965975
"model": "sentry.user",
@@ -6008,9 +5987,6 @@
60085987
[
60095988
"control_file_id"
60105989
],
6011-
[
6012-
"file_id"
6013-
],
60145990
[
60155991
"ident"
60165992
],

fixtures/backup/model_dependencies/flat.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@
240240
"sentry.docintegration": [],
241241
"sentry.docintegrationavatar": [
242242
"sentry.controlfile",
243-
"sentry.docintegration",
244-
"sentry.file"
243+
"sentry.docintegration"
245244
],
246245
"sentry.email": [],
247246
"sentry.environment": [
@@ -763,7 +762,6 @@
763762
],
764763
"sentry.sentryappavatar": [
765764
"sentry.controlfile",
766-
"sentry.file",
767765
"sentry.sentryapp"
768766
],
769767
"sentry.sentryappcomponent": [
@@ -823,7 +821,6 @@
823821
"sentry.user": [],
824822
"sentry.useravatar": [
825823
"sentry.controlfile",
826-
"sentry.file",
827824
"sentry.user"
828825
],
829826
"sentry.useremail": [

fixtures/backup/model_dependencies/sorted.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"sentry.controltombstone",
1515
"sentry.deletedorganization",
1616
"sentry.docintegration",
17+
"sentry.docintegrationavatar",
1718
"sentry.fileblob",
1819
"sentry.identityprovider",
1920
"sentry.integration",
@@ -51,6 +52,7 @@
5152
"sentry.team",
5253
"sentry.teamreplica",
5354
"sentry.user",
55+
"sentry.useravatar",
5456
"sentry.userip",
5557
"sentry.useroption",
5658
"sentry.userpermission",
@@ -92,7 +94,6 @@
9294
"sentry.eventattachment",
9395
"sentry.environment",
9496
"sentry.email",
95-
"sentry.docintegrationavatar",
9697
"sentry.distribution",
9798
"sentry.discoversavedquery",
9899
"sentry.deploy",
@@ -124,7 +125,6 @@
124125
"feedback.feedback",
125126
"sentry.userreport",
126127
"sentry.useremail",
127-
"sentry.useravatar",
128128
"sentry.teamkeytransaction",
129129
"sentry.snubaquery",
130130
"sentry.sentryapp",

fixtures/backup/model_dependencies/truncate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"sentry_controltombstone",
1515
"sentry_deletedorganization",
1616
"sentry_docintegration",
17+
"sentry_docintegrationavatar",
1718
"sentry_fileblob",
1819
"sentry_identityprovider",
1920
"sentry_integration",
@@ -51,6 +52,7 @@
5152
"sentry_team",
5253
"sentry_teamreplica",
5354
"auth_user",
55+
"sentry_useravatar",
5456
"sentry_userip",
5557
"sentry_useroption",
5658
"sentry_userpermission",
@@ -92,7 +94,6 @@
9294
"sentry_eventattachment",
9395
"sentry_environment",
9496
"sentry_email",
95-
"sentry_docintegrationavatar",
9697
"sentry_distribution",
9798
"sentry_discoversavedquery",
9899
"sentry_deploy",
@@ -124,7 +125,6 @@
124125
"feedback_feedback",
125126
"sentry_userreport",
126127
"sentry_useremail",
127-
"sentry_useravatar",
128128
"sentry_performanceteamkeytransaction",
129129
"sentry_snubaquery",
130130
"sentry_sentryapp",

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ feedback: 0004_index_together
99
hybridcloud: 0016_add_control_cacheversion
1010
nodestore: 0002_nodestore_no_dictfield
1111
replays: 0004_index_together
12-
sentry: 0697_remove_monitor_owner_actor_id_db
12+
sentry: 0698_remove_file_id_from_control_avatars
1313
social_auth: 0002_default_auto_field
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 5.0.3 on 2024-04-15 18:26
2+
3+
from django.db import migrations
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
# This flag is used to mark that a migration shouldn't be automatically run in production.
10+
# This should only be used for operations where it's safe to run the migration after your
11+
# code has deployed. So this should not be used for most operations that alter the schema
12+
# of a table.
13+
# Here are some things that make sense to mark as post deployment:
14+
# - Large data migrations. Typically we want these to be run manually so that they can be
15+
# monitored and not block the deploy for a long period of time while they run.
16+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
17+
# run this outside deployments so that we don't block them. Note that while adding an index
18+
# is a schema change, it's completely safe to run the operation after the code has deployed.
19+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
20+
21+
is_post_deployment = False
22+
23+
dependencies = [
24+
("sentry", "0697_remove_monitor_owner_actor_id_db"),
25+
]
26+
27+
operations = [
28+
migrations.SeparateDatabaseAndState(
29+
database_operations=[],
30+
state_operations=[
31+
migrations.RemoveField(
32+
model_name="docintegrationavatar",
33+
name="file_id",
34+
),
35+
migrations.RemoveField(
36+
model_name="sentryappavatar",
37+
name="file_id",
38+
),
39+
migrations.RemoveField(
40+
model_name="useravatar",
41+
name="file_id",
42+
),
43+
],
44+
)
45+
]

src/sentry/models/avatars/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from sentry import options
1414
from sentry.backup.scopes import RelocationScope
1515
from sentry.db.models import Model
16-
from sentry.db.models.fields.bounded import BoundedBigIntegerField
1716
from sentry.models.files.control_file import ControlFile
1817
from sentry.models.files.file import File
1918
from sentry.silo import SiloMode
@@ -37,8 +36,6 @@ class AvatarBase(Model):
3736
FILE_TYPE: ClassVar[str]
3837

3938
ident = models.CharField(max_length=32, unique=True, db_index=True)
40-
# Deprecated, will be moved to OrganizationAvatar soon
41-
file_id = BoundedBigIntegerField(unique=True, null=True)
4239

4340
class Meta:
4441
abstract = True

src/sentry/tasks/files.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
from datetime import timedelta
32

43
from django.db import DatabaseError, IntegrityError, router
@@ -9,8 +8,6 @@
98
from sentry.tasks.deletion.scheduled import MAX_RETRIES
109
from sentry.utils.db import atomic_transaction
1110

12-
logger = logging.getLogger(__name__)
13-
1411

1512
@instrumented_task(
1613
name="sentry.tasks.files.delete_file",
@@ -104,26 +101,3 @@ def delete_unreferenced_blobs(blob_model, blob_index_model, blob_ids):
104101
# Do nothing if the blob was deleted in another task, or
105102
# if had another reference added concurrently.
106103
pass
107-
108-
109-
# TODO(mark): Remove this after no tasks are confirmed
110-
@instrumented_task(
111-
name="sentry.tasks.files.copy_to_control",
112-
queue="files.copy",
113-
default_retry_delay=60 * 5,
114-
max_retries=MAX_RETRIES,
115-
autoretry_for=(DatabaseError, IntegrityError),
116-
acks_late=True,
117-
)
118-
def copy_file_to_control_and_update_model(
119-
app_name: str,
120-
model_name: str,
121-
model_id: int,
122-
file_id: int,
123-
**kwargs,
124-
):
125-
# Shouldn't happen but we can confirm after deploy
126-
logger.info(
127-
"copy_file_to_control_and_update_model.spawned",
128-
extra={"model_name": model_name, "model_id": model_id, "file_id": file_id},
129-
)

tests/sentry/backup/snapshots/test_comparators/test_default_comparators.pysnap

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
created: '2024-04-12T19:46:00.491186+00:00'
2+
created: '2024-04-15T19:02:42.654156+00:00'
33
creator: sentry
44
source: tests/sentry/backup/test_comparators.py
55
---
@@ -458,7 +458,6 @@ source: tests/sentry/backup/test_comparators.py
458458
fields:
459459
- control_file_id
460460
- doc_integration
461-
- file_id
462461
model_name: sentry.docintegrationavatar
463462
- comparators:
464463
- class: EmailObfuscatingComparator
@@ -1390,7 +1389,6 @@ source: tests/sentry/backup/test_comparators.py
13901389
- class: ForeignKeyComparator
13911390
fields:
13921391
- control_file_id
1393-
- file_id
13941392
- sentry_app
13951393
model_name: sentry.sentryappavatar
13961394
- comparators:
@@ -1530,7 +1528,6 @@ source: tests/sentry/backup/test_comparators.py
15301528
- class: ForeignKeyComparator
15311529
fields:
15321530
- control_file_id
1533-
- file_id
15341531
- user
15351532
model_name: sentry.useravatar
15361533
- comparators:

0 commit comments

Comments
 (0)