Skip to content

Commit

Permalink
ref(relay): Remove sentry:relay-rev for project configs (#75521)
Browse files Browse the repository at this point in the history
See: getsentry/relay#3887

Replaces the `sentry:relay-rev` with just a unique id per generation.
  • Loading branch information
Dav1dde authored Aug 5, 2024
1 parent e28618c commit ca62842
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 486 deletions.
18 changes: 0 additions & 18 deletions fixtures/backup/fresh-install.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,24 +410,6 @@
"role": null
}
},
{
"model": "sentry.projectoption",
"pk": 1,
"fields": {
"project": 1,
"key": "sentry:relay-rev",
"value": "\"883653e754e441f9aa54052b52482bdb\""
}
},
{
"model": "sentry.projectoption",
"pk": 2,
"fields": {
"project": 1,
"key": "sentry:relay-rev-lastchange",
"value": "\"2023-06-22T22:54:29.060271Z\""
}
},
{
"model": "sentry.projectoption",
"pk": 3,
Expand Down
7 changes: 0 additions & 7 deletions src/sentry/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from django.utils.translation import gettext_lazy as _

from bitfield import TypedClassBitField
from sentry import projectoptions
from sentry.backup.dependencies import PrimaryKeyMap
from sentry.backup.helpers import ImportFlags
from sentry.backup.scopes import ImportScope, RelocationScope
Expand Down Expand Up @@ -385,7 +384,6 @@ def save(self, *args, **kwargs):
)
else:
super().save(*args, **kwargs)
self.update_rev_for_option()

def get_absolute_url(self, params=None):
path = f"/organizations/{self.organization.slug}/issues/"
Expand Down Expand Up @@ -424,16 +422,11 @@ def get_option(
return self.option_manager.get_value(self, key, default, validate)

def update_option(self, key: str, value: Any) -> bool:
projectoptions.update_rev_for_option(self)
return self.option_manager.set_value(self, key, value)

def delete_option(self, key: str) -> None:
projectoptions.update_rev_for_option(self)
self.option_manager.unset_value(self, key)

def update_rev_for_option(self):
return projectoptions.update_rev_for_option(self)

@property
def color(self):
if self.forced_color is not None:
Expand Down
1 change: 0 additions & 1 deletion src/sentry/projectoptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
all = default_manager.all
isset = default_manager.isset
lookup_well_known_key = default_manager.lookup_well_known_key
update_rev_for_option = default_manager.update_rev_for_option


def get_well_known_default(key, project=None, epoch=None):
Expand Down
16 changes: 0 additions & 16 deletions src/sentry/projectoptions/manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import bisect
import uuid
from datetime import datetime, timezone

from sentry.utils import json


class WellKnownProjectOption:
Expand Down Expand Up @@ -52,7 +48,6 @@ def freeze_option_epoch(self, project, force=False):
def set(self, project, key, value):
from sentry.models.options.project_option import ProjectOption

self.update_rev_for_option(project)
return ProjectOption.objects.set_value(project, key, value)

def isset(self, project, key):
Expand All @@ -64,19 +59,8 @@ def get(self, project, key, default=None, validate=None):
def delete(self, project, key):
from sentry.models.options.project_option import ProjectOption

self.update_rev_for_option(project)
return ProjectOption.objects.unset_value(project, key)

def update_rev_for_option(self, project):
from sentry.models.options.project_option import ProjectOption

ProjectOption.objects.set_value(project, "sentry:relay-rev", uuid.uuid4().hex)
ProjectOption.objects.set_value(
project,
"sentry:relay-rev-lastchange",
json.datetime_to_str(datetime.now(timezone.utc)),
)

def register(self, key, default=None, epoch_defaults=None):
self.registry[key] = WellKnownProjectOption(
key=key, default=default, epoch_defaults=epoch_defaults
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/relay/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ def _get_project_config(
"disabled": False,
"slug": project.slug,
"lastFetch": now,
"lastChange": project.get_option("sentry:relay-rev-lastchange", now),
"rev": project.get_option("sentry:relay-rev", uuid.uuid4().hex),
"lastChange": now,
"rev": uuid.uuid4().hex,
"publicKeys": public_keys,
"config": {
"allowedDomains": list(get_origins(project)),
Expand Down
Loading

0 comments on commit ca62842

Please sign in to comment.