diff --git a/README.md b/README.md index 10450a584a..a35f81c6a0 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ This wizard will, generally, run whenever the server is launched without detecti Create an `appsettings.Production.json` file next to `appsettings.json`. This will override the default settings in appsettings.json with your production settings. There are a few keys meant to be changed by hosts. Modifying any config files while the server is running will trigger a safe restart (Keeps DreamDaemon's running). Note these are all case-sensitive: +- `General:ConfigVersion`: Suppresses warnings about out of date config versions. You should change this after updating TGS to one with a new config version. The current version can be found on the releases page for your server version (This field did not exist before v4.4.0). + - `General:MinimumPasswordLength`: Minimum password length requirement for database users - `General:ValidInstancePaths`: Array meant to limit the directories in which instances may be created. diff --git a/build/Version.props b/build/Version.props index e68888800a..54cf30d7a6 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,6 +3,7 @@ 4.4.0 + 2.0.0 7.0.0 7.3.0 5.2.2 diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index d76ab47826..4e67615cb7 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -280,6 +280,8 @@ namespace Tgstation.Server.Host.Components try { + generalConfiguration.CheckCompatibility(logger); + CheckSystemCompatibility(); var factoryStartup = instanceFactory.StartAsync(cancellationToken); await databaseSeeder.Initialize(databaseContext, cancellationToken).ConfigureAwait(false); diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index 4f617cdd33..7c116a791e 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -1,5 +1,7 @@ -using Newtonsoft.Json; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using System; using Tgstation.Server.Api.Models.Internal; namespace Tgstation.Server.Host.Configuration @@ -19,6 +21,11 @@ namespace Tgstation.Server.Host.Configuration /// public const ushort DefaultApiPort = 5000; + /// + /// The current . + /// + public static readonly Version CurrentConfigVersion = new Version(2, 0, 0); + /// /// The default value for . /// @@ -44,6 +51,11 @@ namespace Tgstation.Server.Host.Configuration /// const uint DefaultRestartTimeout = 60000; + /// + /// The the file says it is. + /// + public Version ConfigVersion { get; set; } + /// /// The port the TGS API listens on. /// @@ -89,5 +101,27 @@ namespace Tgstation.Server.Host.Configuration InstanceLimit = DefaultInstanceLimit; UserLimit = DefaultUserLimit; } + + /// + /// Validates the current 's compatibility and provides migration instructions. + /// + /// The to use. + public void CheckCompatibility(ILogger logger) + { + if (logger == null) + throw new ArgumentNullException(nameof(logger)); + + if (ConfigVersion == null) + logger.LogCritical( + "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{0}\"", + CurrentConfigVersion); + else if (ConfigVersion != CurrentConfigVersion) + if (ConfigVersion.Major != CurrentConfigVersion.Major) + logger.LogCritical( + "Your `ConfigVersion` is majorly out-of-date and may potentially cause issues running the server. Please follow migration instructions from the TGS release notes.", + CurrentConfigVersion); + else + logger.LogWarning("Your `ConfigVersion` is out-of-date. Please follow migration instructions from the TGS release notes."); + } } } diff --git a/src/Tgstation.Server.Host/Configuration/README.md b/src/Tgstation.Server.Host/Configuration/README.md new file mode 100644 index 0000000000..50f05e1290 --- /dev/null +++ b/src/Tgstation.Server.Host/Configuration/README.md @@ -0,0 +1,5 @@ +# Configuration Classes + +These types map directly to the settings used in the [appsettings.json](../appsettings.json) file and its derivatives. See the [Microsoft Docs on the ASP .NET Core configuration system](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1) for details. + +When making changes here, it's important to also update the config version in [build/Version.props](../../../build/Version.props) according to semver semantics. You'll also need to update the constant in [GeneralConfiguration.cs](./GeneralConfigration.cs). \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index 5ee9c3261f..37984ab962 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -745,6 +745,7 @@ namespace Tgstation.Server.Host.Setup await console.WriteAsync(String.Format(CultureInfo.InvariantCulture, "Configuration complete! Saving to {0}", userConfigFileName), true, cancellationToken).ConfigureAwait(false); newGeneralConfiguration.ApiPort = hostingPort ?? GeneralConfiguration.DefaultApiPort; + newGeneralConfiguration.ConfigVersion = GeneralConfiguration.CurrentConfigVersion; var map = new Dictionary() { { DatabaseConfiguration.Section, databaseConfiguration }, diff --git a/tests/Tgstation.Server.Tests/VersionsTest.cs b/tests/Tgstation.Server.Tests/VersionsTest.cs index 0bc638dec2..e3523c3d0d 100644 --- a/tests/Tgstation.Server.Tests/VersionsTest.cs +++ b/tests/Tgstation.Server.Tests/VersionsTest.cs @@ -9,6 +9,7 @@ using Tgstation.Server.Client; using Tgstation.Server.Host; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Watchdog; +using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Tests { @@ -40,6 +41,16 @@ namespace Tgstation.Server.Tests Assert.AreEqual(expected, actual); } + [TestMethod] + public void TestConfigVersion() + { + var versionString = versionsPropertyGroup.Element(xmlNamespace + "TgsConfigVersion").Value; + Assert.IsNotNull(versionString); + Assert.IsTrue(Version.TryParse(versionString, out var expected)); + var actual = GeneralConfiguration.CurrentConfigVersion; + Assert.AreEqual(expected, actual); + } + [TestMethod] public void TestApiVersion() { diff --git a/tools/ReleaseNotes/Program.cs b/tools/ReleaseNotes/Program.cs index 5a2dcf60ae..a068afd658 100644 --- a/tools/ReleaseNotes/Program.cs +++ b/tools/ReleaseNotes/Program.cs @@ -250,6 +250,7 @@ namespace ReleaseNotes } var apiVersion = Version.Parse(versionsPropertyGroup.Element(xmlNamespace + "TgsApiVersion").Value); + var configVersion = Version.Parse(versionsPropertyGroup.Element(xmlNamespace + "TgsConfigVersion").Value); var dmApiVersion = Version.Parse(versionsPropertyGroup.Element(xmlNamespace + "TgsDmapiVersion").Value); var webControlVersion = Version.Parse(versionsPropertyGroup.Element(xmlNamespace + "TgsControlPanelVersion").Value); var hostWatchdogVersion = Version.Parse(versionsPropertyGroup.Element(xmlNamespace + "TgsHostWatchdogVersion").Value); @@ -257,7 +258,7 @@ namespace ReleaseNotes if (webControlVersion.Major == 0) postControlPanelMessage = true; - prefix = $"Please refer to the [README](https://github.com/tgstation/tgstation-server#setup) for setup instructions.{Environment.NewLine}{Environment.NewLine}#### Component Versions\nCore: {coreVersion}\nHTTP API: {apiVersion}\nDreamMaker API: {dmApiVersion}\n[Web Control Panel](https://github.com/tgstation/tgstation-server-control-panel): {webControlVersion}\nHost Watchdog: {hostWatchdogVersion}"; + prefix = $"Please refer to the [README](https://github.com/tgstation/tgstation-server#setup) for setup instructions.{Environment.NewLine}{Environment.NewLine}#### Component Versions\nCore: {coreVersion}\nConfiguration: {configVersion}\nHTTP API: {apiVersion}\nDreamMaker API: {dmApiVersion}\n[Web Control Panel](https://github.com/tgstation/tgstation-server-control-panel): {webControlVersion}\nHost Watchdog: {hostWatchdogVersion}"; break; case 3: prefix = "The /tg/station server suite";