Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,11 @@ def build_cdc_postgres_init_db_volume(settings):
STATUS_PAGE_ID = None
STATUS_PAGE_API_HOST = "statuspage.io"

SENTRY_ONPREMISE = True
# Downstream apps (getsentry, single-tenant) set SENTRY_ONPREMISE, so keep
# reading from that for now, but in the rest of _this_ codebase we should
# reference SENTRY_SELF_HOSTED.
SENTRY_ONPREMISE = True # deprecated, use ...
SENTRY_SELF_HOSTED = SENTRY_ONPREMISE # ... this instead
Copy link
Member Author

@chadwhitacre chadwhitacre Dec 9, 2021

Choose a reason for hiding this comment

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

This is all wrong. I need to actually test this in getsentry. How do I do that?

The result of this PR will be to always set SENTRY_SELF_HOSTED to true, regardless of the value of SENTRY_ONPREMISE in a downstream project. Since SENTRY_SELF_HOSTED then becomes the config passed out to the frontend, if I merge/deploy this then I will effectively turn SaaS into a self-hosted instance.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@chadwhitacre chadwhitacre Dec 9, 2021

Choose a reason for hiding this comment

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

The better way to do this is to:

  1. Set SENTRY_SELF_HOSTED in the downstream apps (getsentry and single-tenant) as a no-op duplicate. It sits right next to SENTRY_ONPREMISE but nothing reads it.
  2. Modify the upstream (i.e., sentry, here) to use/read SENTRY_SELF_HOSTED on the backend (basically this here PR here).
  3. Remove SENTRY_ONPREMISE from the downstreams.
  4. Modify the upstream to set isSelfHosted as a no-op duplicate on the frontend.
  5. Modify the downstreams to read from isSelfHosted.
  6. Modify the upstream to read from isSelfHosted and remove isOnPremise.

The crux is that downstreams set the backend SENTRY_FOO but consume the frontend isFooBar, while upstreams consume the backend and set the frontend. The right approach looks like this:

backend  add    downstream
backend  add    upstream
backend  remove upstream
backend  remove downstream

frontend add    upstream
frontend add    downstream
frontend remove downstream
frontend remove upstream

Copy link
Member Author

Choose a reason for hiding this comment

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

I've folded this back into getsentry/self-hosted#796. To be continued over there ...


# Whether we should look at X-Forwarded-For header or not
# when checking REMOTE_ADDR ip addresses
Expand Down Expand Up @@ -2181,7 +2185,7 @@ def build_cdc_postgres_init_db_volume(settings):
# This should be the url pointing to the JS SDK
JS_SDK_LOADER_DEFAULT_SDK_URL = ""

# block domains which are generally used by spammers -- keep this configurable in case an onpremise
# block domains which are generally used by spammers -- keep this configurable in case a self-hosted
# install wants to allow it
INVALID_EMAIL_ADDRESS_PATTERN = re.compile(r"\@qq\.com$", re.I)

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/web/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_client_config(request=None):
"statuspage": _get_statuspage(),
"messages": [{"message": msg.message, "level": msg.tags} for msg in messages],
"apmSampling": float(settings.SENTRY_FRONTEND_APM_SAMPLING or 0),
"isOnPremise": settings.SENTRY_ONPREMISE,
"isOnPremise": settings.SENTRY_SELF_HOSTED,
Copy link
Member Author

Choose a reason for hiding this comment

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

On this PR, maintain key name used by frontend.

"invitesEnabled": settings.SENTRY_ENABLE_INVITES,
"gravatarBaseUrl": settings.SENTRY_GRAVATAR_BASE_URL,
"termsUrl": settings.TERMS_URL,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/web/frontend/out.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class OutView(View):
def get(self, request):
if not settings.SENTRY_ONPREMISE:
if not settings.SENTRY_SELF_HOSTED:
raise Http404

install_id = options.get("sentry:install-id")
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/web/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_default_context(request, existing_context=None, team=None):
"URL_PREFIX": options.get("system.url-prefix"),
"SINGLE_ORGANIZATION": settings.SENTRY_SINGLE_ORGANIZATION,
"PLUGINS": plugins,
"ONPREMISE": settings.SENTRY_ONPREMISE,
"ONPREMISE": settings.SENTRY_SELF_HOSTED,
}

if existing_context:
Expand Down
2 changes: 1 addition & 1 deletion src/sentry_plugins/sessionstack/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_config(self, project, **kwargs):
},
]

if settings.SENTRY_ONPREMISE:
if settings.SENTRY_SELF_HOSTED:
configurations.extend(
[
{
Expand Down