Skip to content
Merged
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 (i.e., getsentry) sets 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

Choose a reason for hiding this comment

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

This is the risky part. We need to make sure that getsentry (and I guess whatever goofy third-party stuff exists out in the wild) doesn't break. As we can see, SENTRY_ONPREMISE defaults to true, and probably nothing but getsentry overrides that.

Copy link
Member

Choose a reason for hiding this comment

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

Not too important for this pr, but if we want to remove SENTRY_ONPREMISE we should also check with the single tenant team to see whether they set this variable differently as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call @wedamija. This came up at #30528 (comment) as well, and I've put single-tenant on the pile at getsentry/self-hosted#796 to make sure it isn't forgotten. Close one!


# 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
3 changes: 2 additions & 1 deletion src/sentry/web/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ 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, # deprecated, use ...
"isSelfHosted": settings.SENTRY_SELF_HOSTED, # ... this instead
Copy link
Member Author

Choose a reason for hiding this comment

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

Second-riskiest part. getsentry does consume the isOnPremise config key in some places. Third-party JavaScript (plugins?) might as well. Preserve the key!

Copy link
Member

Choose a reason for hiding this comment

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

Will we be removing isOnPremise after getsentry is updated?

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'd like to, but I'm not sure how much impact that has on self-hosters. Probably not much? I'd like to at least get one release out with both keys and a notice in the changelog, then remove "sometime" after that. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I'd imagine it shouldn't affect them, if they are customizing their install, they shouldn't have a need to differentiate between the two? But otherwise sounds good

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.

I mean the default is true. Nobody except us in SaaS should need to change the default. Also yes, like you say, nobody in the wild building their own plugins or whatever should need to vary their behavior on whether this config is true or false, realistically they would just always deliver whatever behavior they're building for their custom app/plugin. I think I'm convinced that we can remove this sooner rather than later (meaning, at the earliest, after getsentry is updated and 21.12.0 goes out).

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm ... single-tenant, though ... 🤔

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.

Yup, PR needed there as well!

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted on getsentry/self-hosted#796. 👍

"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
3 changes: 2 additions & 1 deletion src/sentry/web/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ 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, # deprecated, use ...
"SELF_HOSTED": settings.SENTRY_SELF_HOSTED, # ... this instead
Copy link
Member Author

Choose a reason for hiding this comment

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

What are these contexts? What consumes them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Introduced in #3350 so Django templates can vary:

{% if ONPREMISE %}<a href="/out/">{% trans "Migrate to SaaS" %}</a>{% endif %}

We're not using this anymore, but if we remove this then we should probably remove SINGLE_ORGANIZATION as well, but I want to be conservative here so I am leaving these in.

}

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:
Copy link
Member Author

Choose a reason for hiding this comment

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

Ancient plugin. See settings.tsx.

configurations.extend(
[
{
Expand Down
4 changes: 2 additions & 2 deletions static/app/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function BaseFooter({className}: Props) {
return (
<footer className={className}>
<LeftLinks>
{config.isOnPremise && (
{config.isSelfHosted && (
<Fragment>
{'Sentry '}
{getDynamicText({
Expand Down Expand Up @@ -47,7 +47,7 @@ function BaseFooter({className}: Props) {
<FooterLink href="https://github.com/getsentry/sentry">
{t('Contribute')}
</FooterLink>
{config.isOnPremise && !config.demoMode && (
{config.isSelfHosted && !config.demoMode && (
<FooterLink href="/out/">{t('Migrate to SaaS')}</FooterLink>
)}
</RightLinks>
Expand Down
22 changes: 11 additions & 11 deletions static/app/plugins/sessionstack/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import DefaultSettings from 'sentry/plugins/components/settings';
type Props = DefaultSettings['props'];

type State = DefaultSettings['state'] & {
showOnPremisesConfiguration?: boolean;
showSelfHostedConfiguration?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

This ancient plugin has a few config values that are only relevant on self-hosted. This is the source of the screenshots that changed.

};

class Settings extends DefaultSettings<Props, State> {
REQUIRED_FIELDS = ['account_email', 'api_token', 'website_id'];
ON_PREMISES_FIELDS = ['api_url', 'player_url'];
SELF_HOSTED_FIELDS = ['api_url', 'player_url'];

renderFields(fields: State['fieldList']) {
return fields?.map(f =>
Expand All @@ -29,9 +29,9 @@ class Settings extends DefaultSettings<Props, State> {
return fields?.filter(field => fieldNames.includes(field.name)) ?? [];
}

toggleOnPremisesConfiguration = () => {
toggleSelfHostedConfiguration = () => {
this.setState({
showOnPremisesConfiguration: !this.state.showOnPremisesConfiguration,
showSelfHostedConfiguration: !this.state.showSelfHostedConfiguration,
});
};

Expand All @@ -53,9 +53,9 @@ class Settings extends DefaultSettings<Props, State> {
const hasChanges = !isEqual(this.state.initialData, this.state.formData);

const requiredFields = this.filterFields(this.state.fieldList, this.REQUIRED_FIELDS);
const onPremisesFields = this.filterFields(
const selfHostedFields = this.filterFields(
this.state.fieldList,
this.ON_PREMISES_FIELDS
this.SELF_HOSTED_FIELDS
);

return (
Expand All @@ -68,19 +68,19 @@ class Settings extends DefaultSettings<Props, State> {
</div>
)}
{this.renderFields(requiredFields)}
{onPremisesFields.length > 0 ? (
{selfHostedFields.length > 0 ? (
<div className="control-group">
<button
className="btn btn-default"
type="button"
onClick={this.toggleOnPremisesConfiguration}
onClick={this.toggleSelfHostedConfiguration}
>
Configure on-premises
Configure self-hosted
</button>
</div>
) : null}
{this.state.showOnPremisesConfiguration
? this.renderFields(onPremisesFields)
{this.state.showSelfHostedConfiguration
? this.renderFields(selfHostedFields)
: null}
</Form>
);
Expand Down
3 changes: 2 additions & 1 deletion static/app/types/system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export interface Config {
invitesEnabled: boolean;
privacyUrl: string | null;
termsUrl: string | null;
isOnPremise: boolean;
isOnPremise: boolean; // deprecated, use ...
isSelfHosted: boolean; // ... this instead
lastOrganization: string | null;
gravatarBaseUrl: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class SetupAlertIntegrationButton extends AsyncComponent<Props, S
const config = ConfigStore.getConfig();
// link to docs to set up Slack for on-prem folks
const referrerQuery = '?referrer=issue-alert-builder';
const buttonProps = config.isOnPremise
const buttonProps = config.isSelfHosted
? {
href: `https://develop.sentry.dev/integrations/slack/${referrerQuery}`,
}
Expand Down
12 changes: 6 additions & 6 deletions static/app/views/settings/settingsIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ class SettingsIndex extends React.Component<Props> {
render() {
const {organization} = this.props;
const user = ConfigStore.get('user');
const isOnPremise = ConfigStore.get('isOnPremise');
const isSelfHosted = ConfigStore.get('isSelfHosted');

const organizationSettingsUrl =
(organization && `/settings/${organization.slug}/`) || '';

const supportLinkProps = {
isOnPremise,
isSelfHosted,
href: LINKS.FORUM,
to: `${organizationSettingsUrl}support`,
};
const supportText = isOnPremise ? t('Community Forums') : t('Contact Support');
const supportText = isSelfHosted ? t('Community Forums') : t('Contact Support');
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I should update the forums link as well to keep up with getsentry/self-hosted#1151, but that's out of scope for this repo.


return (
<SentryDocumentTitle
Expand Down Expand Up @@ -340,7 +340,7 @@ const ExternalHomeLink = styled(
`;

type SupportLinkProps<T extends boolean> = {
isOnPremise: T;
isSelfHosted: T;
href: string;
to: string;
isCentered?: boolean;
Expand All @@ -350,12 +350,12 @@ type SupportLinkProps<T extends boolean> = {

const SupportLinkComponent = <T extends boolean>({
isCentered,
isOnPremise,
isSelfHosted,
href,
to,
...props
}: SupportLinkProps<T>) =>
isOnPremise ? (
isSelfHosted ? (
<ExternalHomeLink isCentered={isCentered} href={href} {...props} />
) : (
<HomeLink to={to} {...props} />
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/js-stubs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function Config(params = {}) {
invitesEnabled: false,
privacyUrl: null,
termsUrl: null,
isOnPremise: false,
isOnPremise: false, // deprecated, use ...
isSelfHosted: false, // ... this instead
lastOrganization: null,
gravatarBaseUrl: 'https://gravatar.com',
dsn: 'test-dsn',
Expand Down
6 changes: 3 additions & 3 deletions tests/js/spec/views/settings/settingsIndex.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('SettingsIndex', function () {
expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
});

it('has different links for on premise users', function () {
ConfigStore.set('isOnPremise', true);
it('has different links for self-hosted users', function () {
ConfigStore.set('isSelfHosted', true);

wrapper = mountWithTheme(
<SettingsIndex
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('SettingsIndex', function () {
api = MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/`,
});
ConfigStore.config.isOnPremise = false;
ConfigStore.config.isSelfHosted = false;
wrapper = mountWithTheme(
<SettingsIndex router={TestStubs.router()} params={{}} />,
TestStubs.routerContext()
Expand Down