Skip to content

Commit

Permalink
Merge pull request #1786 from tgstation/1741-Minidumps [APIDeploy][Nu…
Browse files Browse the repository at this point in the history
…getDeploy]

Minidumps
  • Loading branch information
Cyberboss authored Feb 3, 2024
2 parents 15b06c1 + 98801c4 commit ba91a9b
Show file tree
Hide file tree
Showing 32 changed files with 4,566 additions and 45 deletions.
2 changes: 1 addition & 1 deletion build/SrcCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<!-- Usage: Linting -->
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<PropertyGroup>
<TgsCoreVersion>6.1.5</TgsCoreVersion>
<TgsConfigVersion>5.1.0</TgsConfigVersion>
<TgsApiVersion>10.0.0</TgsApiVersion>
<TgsApiVersion>10.1.0</TgsApiVersion>
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>13.0.1</TgsApiLibraryVersion>
<TgsClientVersion>15.0.1</TgsClientVersion>
<TgsApiLibraryVersion>13.1.0</TgsApiLibraryVersion>
<TgsClientVersion>15.1.0</TgsClientVersion>
<TgsDmapiVersion>7.0.2</TgsDmapiVersion>
<TgsInteropVersion>5.8.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.1</TgsHostWatchdogVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public class DreamDaemonLaunchParameters
[ResponseOptions]
public uint? MapThreads { get; set; }

/// <summary>
/// If minidumps should be taken instead of full dumps.
/// </summary>
[Required]
[ResponseOptions]
public bool? Minidumps { get; set; }

/// <summary>
/// Check if we match a given set of <paramref name="otherParameters"/>. <see cref="StartupTimeout"/> is excluded.
/// </summary>
Expand All @@ -116,7 +123,7 @@ public bool CanApplyWithoutReboot(DreamDaemonLaunchParameters otherParameters)
&& AdditionalParameters == otherParameters.AdditionalParameters
&& StartProfiler == otherParameters.StartProfiler
&& LogOutput == otherParameters.LogOutput
&& MapThreads == otherParameters.MapThreads; // We intentionally don't check StartupTimeout, health check seconds, or health check dump as they don't matter in terms of the watchdog
&& MapThreads == otherParameters.MapThreads; // We intentionally don't check StartupTimeout, Minidumps, health check seconds, or health check dump as they don't matter in terms of the watchdog
}
}
}
5 changes: 5 additions & 0 deletions src/Tgstation.Server.Api/Rights/DreamDaemonRights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@ public enum DreamDaemonRights : ulong
/// User can use <see cref="Models.Request.DreamDaemonRequest.BroadcastMessage"/>.
/// </summary>
BroadcastMessage = 1 << 20,

/// <summary>
/// User can use <see cref="Models.Internal.DreamDaemonLaunchParameters.Minidumps"/>.
/// </summary>
SetMinidumps = 1 << 21,
}
}
2 changes: 1 addition & 1 deletion src/Tgstation.Server.Host/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.0",
"version": "8.0.1",
"commands": [
"dotnet-ef"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,12 @@ public async ValueTask UpdateChannels(IEnumerable<ChannelRepresentation> newChan
cancellationToken);

/// <inheritdoc />
public ValueTask CreateDump(string outputFile, CancellationToken cancellationToken)
public ValueTask CreateDump(string outputFile, bool minidump, CancellationToken cancellationToken)
{
if (engineLock.UseDotnetDump)
return dotnetDumpService.Dump(process, outputFile, cancellationToken);
return dotnetDumpService.Dump(process, outputFile, minidump, cancellationToken);

return process.CreateDump(outputFile, cancellationToken);
return process.CreateDump(outputFile, minidump, cancellationToken);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ async ValueTask CreateDumpNoLock(CancellationToken cancellationToken)
throw new JobException(ErrorCode.GameServerOffline);

Logger.LogInformation("Dumping session to {dumpFileName}...", dumpFileName);
await session.CreateDump(dumpFileName, cancellationToken);
await session.CreateDump(dumpFileName, ActiveLaunchParameters.Minidumps!.Value, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public ValueTask<IActionResult> Delete(CancellationToken cancellationToken)
| DreamDaemonRights.SetProfiler
| DreamDaemonRights.SetLogOutput
| DreamDaemonRights.SetMapThreads
| DreamDaemonRights.BroadcastMessage)]
| DreamDaemonRights.BroadcastMessage
| DreamDaemonRights.SetMinidumps)]
[ProducesResponseType(typeof(DreamDaemonResponse), 200)]
[ProducesResponseType(typeof(ErrorMessageResponse), 410)]
#pragma warning disable CA1502 // TODO: Decomplexify
Expand Down Expand Up @@ -222,7 +223,8 @@ bool CheckModified<T>(Expression<Func<Api.Models.Internal.DreamDaemonSettings, T
|| CheckModified(x => x.AdditionalParameters, DreamDaemonRights.SetAdditionalParameters)
|| CheckModified(x => x.StartProfiler, DreamDaemonRights.SetProfiler)
|| CheckModified(x => x.LogOutput, DreamDaemonRights.SetLogOutput)
|| CheckModified(x => x.MapThreads, DreamDaemonRights.SetMapThreads))
|| CheckModified(x => x.MapThreads, DreamDaemonRights.SetMapThreads)
|| CheckModified(x => x.Minidumps, DreamDaemonRights.SetMinidumps))
return Forbid();

return await WithComponentInstance(
Expand Down Expand Up @@ -379,6 +381,7 @@ ValueTask<IActionResult> ReadImpl(DreamDaemonSettings? settings, bool knownForce
result.StartProfiler = settings.StartProfiler;
result.LogOutput = settings.LogOutput;
result.MapThreads = settings.MapThreads;
result.Minidumps = settings.Minidumps;
}

if (revision)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ public async ValueTask<IActionResult> GrantPermissions(long id, CancellationToke
StartProfiler = false,
LogOutput = false,
MapThreads = 0,
Minidumps = true,
},
DreamMakerSettings = new DreamMakerSettings
{
Expand Down
18 changes: 14 additions & 4 deletions src/Tgstation.Server.Host/Database/DatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,22 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
/// <summary>
/// Used by unit tests to remind us to setup the correct MSSQL migration downgrades.
/// </summary>
internal static readonly Type MSLatestMigration = typeof(MSAddTopicPort);
internal static readonly Type MSLatestMigration = typeof(MSAddMinidumpsOption);

/// <summary>
/// Used by unit tests to remind us to setup the correct MYSQL migration downgrades.
/// </summary>
internal static readonly Type MYLatestMigration = typeof(MYAddTopicPort);
internal static readonly Type MYLatestMigration = typeof(MYAddMinidumpsOption);

/// <summary>
/// Used by unit tests to remind us to setup the correct PostgresSQL migration downgrades.
/// </summary>
internal static readonly Type PGLatestMigration = typeof(PGAddTopicPort);
internal static readonly Type PGLatestMigration = typeof(PGAddMinidumpsOption);

/// <summary>
/// Used by unit tests to remind us to setup the correct SQLite migration downgrades.
/// </summary>
internal static readonly Type SLLatestMigration = typeof(SLAddTopicPort);
internal static readonly Type SLLatestMigration = typeof(SLAddMinidumpsOption);

/// <inheritdoc />
#pragma warning disable CA1502 // Cyclomatic complexity
Expand Down Expand Up @@ -419,6 +419,16 @@ public async ValueTask SchemaDowngradeForServerVersion(

string BadDatabaseType() => throw new ArgumentException($"Invalid DatabaseType: {currentDatabaseType}", nameof(currentDatabaseType));

if (targetVersion < new Version(6, 2, 0))
targetMigration = currentDatabaseType switch
{
DatabaseType.MySql => nameof(MYAddTopicPort),
DatabaseType.PostgresSql => nameof(PGAddTopicPort),
DatabaseType.SqlServer => nameof(MSAddTopicPort),
DatabaseType.Sqlite => nameof(SLAddTopicPort),
_ => BadDatabaseType(),
};

if (targetVersion < new Version(6, 0, 0))
targetMigration = currentDatabaseType switch
{
Expand Down
Loading

0 comments on commit ba91a9b

Please sign in to comment.