From 9186b7f7cf6531dd5fbff33ca56a6232662e4cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Jan 2025 10:16:15 +0100 Subject: [PATCH 1/2] Adjust staging environment configuration --- README.md | 54 +++++++++++++++++-------- osu.Server.BeatmapSubmission/Program.cs | 22 ++++++++++ 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a545573..5a1506c 100644 --- a/README.md +++ b/README.md @@ -26,21 +26,41 @@ Additionally, to test beatmap downloads, you may want to set up a local beatmap For advanced testing purposes. -| Envvar name | Description | Mandatory? | Default value | -|:-----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------:|:--------------| -| `DB_HOST` | Hostname under which the `osu-web` MySQL instance can be found. | ❌ No | `localhost` | -| `DB_PORT` | Port under which the `osu-web` MySQL instance can be found. | ❌ No | `3306` | -| `DB_USER` | Username to use when logging into the `osu-web` MySQL instance. | ❌ No | `root` | -| `DB_PASS` | Password to use when logging into the `osu-web` MySQL instance. | ❌ No | `""` | -| `DB_NAME` | Name of database to use on the indicated MySQL instance. | ❌ No | `osu` | -| `JWT_VALID_AUDIENCE` | The value of the `aud` claim to use when validating incoming JWTs. Should be set to the client ID assigned to osu! in the `osu-web` target deploy. | ✔️ Yes | None | -| `LOCAL_BEATMAP_STORAGE_PATH` | The path of a directory where the submitted beatmaps should reside. | ⚠️ In development config | None | -| `LEGACY_IO_DOMAIN` | The root domain to which legacy IO requests should be directed to. | ✔️ Yes | None | -| `SHARED_INTEROP_SECRET` | The interop secret used for legacy IO requests. Value should match same environment variable in target `osu-web` instance. | ✔️ Yes | None | -| `S3_ACCESS_KEY` | A valid Amazon S3 access key ID. | ⚠ In staging/production configs | None | -| `S3_SECRET_KEY` | The secret key corresponding to the `S3_ACCESS_KEY`. | ⚠ In staging/production configs | None | -| `S3_CENTRAL_BUCKET_NAME` | The name of the S3 bucket to use for storing beatmap packages and versioned files. | ⚠ In staging/production configs | None | -| `S3_BEATMAPS_BUCKET_NAME` | The name of the S3 bucket to use for storing .osu beatmap files. | ⚠ In staging/production configs | None | -| `SENTRY_DSN` | A valid Sentry DSN to use for logging application events. | ⚠ In staging/production configs | None | -| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In staging/production configs | None | +This project supports three environment setups. +The choice of the environment is steered by the `ASPNETCORE_ENVIRONMENT` environment variable. +Depending on environment, this service changes behaviour with respect to interactions with external services. + +- `ASPNETCORE_ENVIRONMENT=Development`: + - Local (filesystem-based) beatmap storage is used. + - No purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs (`/api-docs`) are enabled. + - Sentry & Datadog integrations are optional. +- `ASPNETCORE_ENVIRONMENT=Staging`: + - Local (filesystem-based) beatmap storage is used. + - No purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs are disabled. + - Sentry & Datadog integrations are mandatory. +- `ASPNETCORE_ENVIRONMENT=Production`: + - S3-based beatmap storage is used. + - Purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs are disabled. + - Sentry & Datadog integrations are mandatory. + +| Envvar name | Description | Mandatory? | Default value | +|:-----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------:|:--------------| +| `DB_HOST` | Hostname under which the `osu-web` MySQL instance can be found. | ❌ No | `localhost` | +| `DB_PORT` | Port under which the `osu-web` MySQL instance can be found. | ❌ No | `3306` | +| `DB_USER` | Username to use when logging into the `osu-web` MySQL instance. | ❌ No | `root` | +| `DB_PASS` | Password to use when logging into the `osu-web` MySQL instance. | ❌ No | `""` | +| `DB_NAME` | Name of database to use on the indicated MySQL instance. | ❌ No | `osu` | +| `JWT_VALID_AUDIENCE` | The value of the `aud` claim to use when validating incoming JWTs. Should be set to the client ID assigned to osu! in the `osu-web` target deploy. | ✔️ Yes | None | +| `LOCAL_BEATMAP_STORAGE_PATH` | The path of a directory where the submitted beatmaps should reside. | ⚠️ In development & staging environment | None | +| `LEGACY_IO_DOMAIN` | The root domain to which legacy IO requests should be directed to. | ✔️ Yes | None | +| `SHARED_INTEROP_SECRET` | The interop secret used for legacy IO requests. Value should match same environment variable in target `osu-web` instance. | ✔️ Yes | None | +| `S3_ACCESS_KEY` | A valid Amazon S3 access key ID. | ⚠ In production environment | None | +| `S3_SECRET_KEY` | The secret key corresponding to the `S3_ACCESS_KEY`. | ⚠ In production environment | None | +| `S3_CENTRAL_BUCKET_NAME` | The name of the S3 bucket to use for storing beatmap packages and versioned files. | ⚠ In production environment | None | +| `S3_BEATMAPS_BUCKET_NAME` | The name of the S3 bucket to use for storing .osu beatmap files. | ⚠ In production environment | None | +| `SENTRY_DSN` | A valid Sentry DSN to use for logging application events. | ⚠ In staging & production environment | None | +| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In staging & production environment | None | diff --git a/osu.Server.BeatmapSubmission/Program.cs b/osu.Server.BeatmapSubmission/Program.cs index d8113ef..65bffe0 100644 --- a/osu.Server.BeatmapSubmission/Program.cs +++ b/osu.Server.BeatmapSubmission/Program.cs @@ -60,6 +60,28 @@ public static void Main(string[] args) } case "Staging": + { + builder.Services.AddSingleton(); + builder.Services.AddTransient(); + builder.Services.AddHttpClient(); + builder.Services.AddTransient(); + builder.Services.AddTransient(); + + if (AppSettings.SentryDsn == null) + { + throw new InvalidOperationException("SENTRY_DSN environment variable not set. " + + "Please set the value of this variable to a valid Sentry DSN to use for logging events."); + } + + if (AppSettings.DatadogAgentHost == null) + { + throw new InvalidOperationException("DD_AGENT_HOST environment variable not set. " + + "Please set the value of this variable to a valid hostname of a Datadog agent."); + } + + break; + } + case "Production": { builder.Services.AddSingleton(); From 8d398e1714c37a23e6da927ee030169232e98c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Jan 2025 10:59:28 +0100 Subject: [PATCH 2/2] Make datadog optional on staging --- README.md | 5 +++-- osu.Server.BeatmapSubmission/Program.cs | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5a1506c..40a2f9a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,8 @@ Depending on environment, this service changes behaviour with respect to interac - Local (filesystem-based) beatmap storage is used. - No purge requests to beatmap mirrors are made on beatmap updates. - Developer exception pages & API docs are disabled. - - Sentry & Datadog integrations are mandatory. + - Sentry integration is mandatory. + - Datadog integration is optional. - `ASPNETCORE_ENVIRONMENT=Production`: - S3-based beatmap storage is used. - Purge requests to beatmap mirrors are made on beatmap updates. @@ -62,5 +63,5 @@ Depending on environment, this service changes behaviour with respect to interac | `S3_CENTRAL_BUCKET_NAME` | The name of the S3 bucket to use for storing beatmap packages and versioned files. | ⚠ In production environment | None | | `S3_BEATMAPS_BUCKET_NAME` | The name of the S3 bucket to use for storing .osu beatmap files. | ⚠ In production environment | None | | `SENTRY_DSN` | A valid Sentry DSN to use for logging application events. | ⚠ In staging & production environment | None | -| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In staging & production environment | None | +| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In production environment | None | diff --git a/osu.Server.BeatmapSubmission/Program.cs b/osu.Server.BeatmapSubmission/Program.cs index 65bffe0..4e74299 100644 --- a/osu.Server.BeatmapSubmission/Program.cs +++ b/osu.Server.BeatmapSubmission/Program.cs @@ -73,12 +73,6 @@ public static void Main(string[] args) + "Please set the value of this variable to a valid Sentry DSN to use for logging events."); } - if (AppSettings.DatadogAgentHost == null) - { - throw new InvalidOperationException("DD_AGENT_HOST environment variable not set. " - + "Please set the value of this variable to a valid hostname of a Datadog agent."); - } - break; }