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

chore(hybrid-cloud): ORM decorators updated. #40022

Merged
merged 3 commits into from Oct 14, 2022

Conversation

corps
Copy link
Member

@corps corps commented Oct 14, 2022

As per the most recent discussion wrt hybrid cloud, models are now one of 3 possibilities:

  1. Only in control silo, cannot be read from region silo
  2. Control silo with replication to region silo, cannot be written to from region silo
  3. Region silo only, cannot be read from control silo

Creating these three decorators and giving them updated names to reflect the new strategy. NOTE the decorators are still no-ops in production, and are likely to change as me and @RyanSkonnord move forward with locking these down.

Also, removed all_silo_model as it seems that no model will be allowed to exist in all silo modes.

Models now have 3 states: control silo only, control silo with
replication, and region silo only.  Update our decorators
to reflect that.
@corps corps requested a review from a team as a code owner October 14, 2022 05:22
@corps corps requested a review from a team October 14, 2022 05:22
@corps corps requested a review from a team as a code owner October 14, 2022 05:22
@corps corps requested a review from a team October 14, 2022 05:22
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 14, 2022
@corps
Copy link
Member Author

corps commented Oct 14, 2022

getsentry is updated here https://github.com/getsentry/getsentry/pull/8577

@@ -224,7 +224,7 @@ class Meta:
db_table = "sentry_incidentsnapshot"


@control_silo_model
@control_silo_with_replication_model
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need replication?



@control_silo_model
@control_silo_with_replication_model
Copy link
Member

Choose a reason for hiding this comment

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

This should be region only. 🤔



@control_silo_model
@control_silo_with_replication_model
Copy link
Member

Choose a reason for hiding this comment

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

This should be region only too.

@@ -22,7 +22,7 @@ class Meta:
db_table = "sentry_relayusage"


@control_silo_model
@control_silo_with_replication_model
Copy link
Member

Choose a reason for hiding this comment

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

Region only here too.

@@ -15,7 +15,7 @@
from typing import Mapping, Type


@control_silo_model
@control_silo_with_replication_model
Copy link
Member

Choose a reason for hiding this comment

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

region silo here too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. To be clear, this PR's sole focus is getting the orm decorators 1. renamed and 2. adding the new decorator focused on the replicated vs non replicated case.

I am not, focused on getting the decorators in the correct state. That would be this story: https://getsentry.atlassian.net/browse/HC-243

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, given that this is a decorator rename, in order to support https://github.com/getsentry/getsentry/pull/8577 can I, merge these two within short time when both are green and good, or is it required that I only merge this PR in with a backwards compatible naming, and merge an additional PR removing that rename after the getsentry pr?

Copy link
Member

@RyanSkonnord RyanSkonnord left a comment

Choose a reason for hiding this comment

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

Conceptually, looks good to me! I'm not sure about every individual model but we can always change those as we go.

One consideration: we were tentatively committed to letting scripts/silo/ be a source of truth and to change model decorators only by updating and rerunning those scripts. I'm 100% okay with abandoning that approach if it isn't worthwhile, but we might want to drop a comment into those scripts, maybe a pointer to this PR, or just delete them entirely if we're feeling bold.

all_silo_model = ModelSiloLimit(*SiloMode)
control_silo_with_replication_model = ModelSiloLimit(SiloMode.CONTROL, read_only=SiloMode.REGION)
control_silo_only_model = ModelSiloLimit(SiloMode.CONTROL)
region_silo_only_model = ModelSiloLimit(SiloMode.REGION)
Copy link
Member

Choose a reason for hiding this comment

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

If these global decorator aliases become more trouble than they're worth, I wouldn't be opposed to ditching them and just referring to ModelSiloLimit directly, as in

@ModelSiloLimit(SiloMode.CONTROL, read_only=SiloMode.REGION)
class TimeSeriesSnapshot(Model):

I'm not going to advocate for that yet because "control silo with replication model" is a useful name that conveys information. But, if find ourselves adding more cases with increasingly verbose names, I wouldn't want to see it sprawl into an unmanageable menagerie of decorators. In that case, I'd think it's important to let the init parameters tell the whole story and refactor until they make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fair. Hopefully this is the final story for our data split, but if it does grow any more complex, I agree that we can just let the parameterization speak for itself.

@corps corps merged commit ece6d6c into master Oct 14, 2022
@corps corps deleted the zc/clarify-model-orm-decorators branch October 14, 2022 21:23
barkbarkimashark pushed a commit that referenced this pull request Oct 18, 2022
Updating model decorator names reflecting newest hybrid cloud requirements.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2022
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.

None yet

3 participants