mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 07:04:57 +01:00
Fix EngineManager not respecting Session:LowPriorityDeploymentProcesses
This commit is contained in:
@@ -41,8 +41,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
=> DelegateCall(version, installer => installer.DownloadVersion(version, jobProgressReporter, cancellationToken));
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask Install(EngineVersion version, string path, CancellationToken cancellationToken)
|
||||
=> DelegateCall(version, installer => installer.Install(version, path, cancellationToken));
|
||||
public ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
=> DelegateCall(version, installer => installer.Install(version, path, deploymentPipelineProcesses, cancellationToken));
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
public abstract Task CleanCache(CancellationToken cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract ValueTask Install(EngineVersion version, string path, CancellationToken cancellationToken);
|
||||
public abstract ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken);
|
||||
|
||||
@@ -463,6 +463,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
installLock = installationContainer.AddReference();
|
||||
}
|
||||
|
||||
var deploymentPipelineProcesses = !neededForLock;
|
||||
try
|
||||
{
|
||||
if (installedOrInstalling)
|
||||
@@ -496,26 +497,26 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
progressReporter.StageName = "Running event";
|
||||
|
||||
var versionString = version.ToString();
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallStart, new List<string> { versionString }, false, cancellationToken);
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallStart, new List<string> { versionString }, deploymentPipelineProcesses, cancellationToken);
|
||||
|
||||
if (installLock.UseDotnetDump)
|
||||
{
|
||||
if (progressReporter != null)
|
||||
progressReporter.StageName = "Installing dotnet-dump";
|
||||
|
||||
await dotnetDumpService.EnsureInstalled(false, cancellationToken);
|
||||
await dotnetDumpService.EnsureInstalled(deploymentPipelineProcesses, cancellationToken);
|
||||
}
|
||||
|
||||
await InstallVersionFiles(progressReporter, version, customVersionStream, cancellationToken);
|
||||
await InstallVersionFiles(progressReporter, version, customVersionStream, deploymentPipelineProcesses, cancellationToken);
|
||||
|
||||
ourTcs.SetResult();
|
||||
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallComplete, new List<string> { versionString }, false, cancellationToken);
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallComplete, new List<string> { versionString }, deploymentPipelineProcesses, cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is not OperationCanceledException)
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallFail, new List<string> { ex.Message }, false, cancellationToken);
|
||||
await eventConsumer.HandleEvent(EventType.EngineInstallFail, new List<string> { ex.Message }, deploymentPipelineProcesses, cancellationToken);
|
||||
|
||||
lock (installedVersions)
|
||||
installedVersions.Remove(version);
|
||||
@@ -539,9 +540,15 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <param name="progressReporter">The optional <see cref="JobProgressReporter"/> for the operation.</param>
|
||||
/// <param name="version">The <see cref="EngineVersion"/> being installed with the <see cref="Version.Build"/> number set if appropriate.</param>
|
||||
/// <param name="customVersionStream">Custom zip file <see cref="Stream"/> to use. Will cause a <see cref="Version.Build"/> number to be added.</param>
|
||||
/// <param name="deploymentPipelineProcesses">If processes should be launched as part of the deployment pipeline.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
async ValueTask InstallVersionFiles(JobProgressReporter? progressReporter, EngineVersion version, Stream? customVersionStream, CancellationToken cancellationToken)
|
||||
async ValueTask InstallVersionFiles(
|
||||
JobProgressReporter? progressReporter,
|
||||
EngineVersion version,
|
||||
Stream? customVersionStream,
|
||||
bool deploymentPipelineProcesses,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var installFullPath = ioManager.ResolvePath(version.ToString());
|
||||
async ValueTask DirectoryCleanup()
|
||||
@@ -587,7 +594,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
if (progressReporter != null)
|
||||
progressReporter.StageName = "Running installation actions";
|
||||
|
||||
await engineInstaller.Install(version, installFullPath, cancellationToken);
|
||||
await engineInstaller.Install(version, installFullPath, deploymentPipelineProcesses, cancellationToken);
|
||||
|
||||
if (progressReporter != null)
|
||||
progressReporter.StageName = "Writing version file";
|
||||
|
||||
@@ -34,9 +34,10 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// </summary>
|
||||
/// <param name="version">The <see cref="EngineVersion"/> being installed.</param>
|
||||
/// <param name="path">The path to the installation.</param>
|
||||
/// <param name="deploymentPipelineProcesses">If the operation should consider processes it launches to be part of the deployment pipeline.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
ValueTask Install(EngineVersion version, string path, CancellationToken cancellationToken);
|
||||
ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Does actions necessary to get upgrade a version installed by a previous version of TGS.
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async ValueTask Install(EngineVersion version, string installPath, CancellationToken cancellationToken)
|
||||
public override async ValueTask Install(EngineVersion version, string installPath, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
CheckVersionValidity(version);
|
||||
ArgumentNullException.ThrowIfNull(installPath);
|
||||
@@ -247,7 +247,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
!GeneralConfiguration.OpenDreamSuppressInstallOutput,
|
||||
!GeneralConfiguration.OpenDreamSuppressInstallOutput);
|
||||
|
||||
if (SessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
if (deploymentPipelineProcesses && SessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
buildProcess.AdjustPriority(false);
|
||||
|
||||
using (cancellationToken.Register(() => buildProcess.Terminate()))
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ValueTask Install(EngineVersion version, string path, CancellationToken cancellationToken)
|
||||
public override ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
CheckVersionValidity(version);
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
public void Dispose() => semaphore.Dispose();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ValueTask Install(EngineVersion version, string path, CancellationToken cancellationToken)
|
||||
public override ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
CheckVersionValidity(version);
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
@@ -142,7 +142,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
|
||||
if (!generalConfiguration.SkipAddingByondFirewallException)
|
||||
{
|
||||
var firewallTask = AddDreamDaemonToFirewall(version, path, cancellationToken);
|
||||
var firewallTask = AddDreamDaemonToFirewall(version, path, deploymentPipelineProcesses, cancellationToken);
|
||||
tasks.Add(firewallTask);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
return;
|
||||
|
||||
Logger.LogInformation("BYOND Version {version} needs dd.exe added to firewall", version);
|
||||
await AddDreamDaemonToFirewall(version, path, cancellationToken);
|
||||
await AddDreamDaemonToFirewall(version, path, true, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -243,9 +243,10 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// </summary>
|
||||
/// <param name="version">The BYOND <see cref="EngineVersion"/>.</param>
|
||||
/// <param name="path">The path to the BYOND installation.</param>
|
||||
/// <param name="deploymentPipelineProcesses">If the operation is part of the deployment pipeline.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
async ValueTask AddDreamDaemonToFirewall(EngineVersion version, string path, CancellationToken cancellationToken)
|
||||
async ValueTask AddDreamDaemonToFirewall(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
var dreamDaemonName = GetDreamDaemonName(version.Version!, out var usesDDExe);
|
||||
|
||||
@@ -268,7 +269,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
Logger,
|
||||
ruleName,
|
||||
dreamDaemonPath,
|
||||
sessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
deploymentPipelineProcesses && sessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -66,15 +66,17 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ValueTask Install(EngineVersion version, string installPath, CancellationToken cancellationToken)
|
||||
public override ValueTask Install(EngineVersion version, string installPath, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
var installTask = base.Install(
|
||||
version,
|
||||
installPath,
|
||||
deploymentPipelineProcesses,
|
||||
cancellationToken);
|
||||
var firewallTask = AddServerFirewallException(
|
||||
version,
|
||||
installPath,
|
||||
deploymentPipelineProcesses,
|
||||
cancellationToken);
|
||||
|
||||
return ValueTaskExtensions.WhenAll(installTask, firewallTask);
|
||||
@@ -101,9 +103,10 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// </summary>
|
||||
/// <param name="version">The BYOND <see cref="EngineVersion"/>.</param>
|
||||
/// <param name="path">The path to the BYOND installation.</param>
|
||||
/// <param name="deploymentPipelineProcesses">If the operation is part of the deployment pipeline.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
async ValueTask AddServerFirewallException(EngineVersion version, string path, CancellationToken cancellationToken)
|
||||
async ValueTask AddServerFirewallException(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
if (GeneralConfiguration.SkipAddingByondFirewallException)
|
||||
return;
|
||||
@@ -123,7 +126,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
Logger,
|
||||
ruleName,
|
||||
serverExePath,
|
||||
SessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
deploymentPipelineProcesses && SessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Tgstation.Server.Host.Components.Engine.Tests
|
||||
var installer = new PosixByondInstaller(mockPostWriteHandler.Object, mockIOManager.Object, mockFileDownloader, mockLogger.Object);
|
||||
|
||||
const string FakePath = "fake";
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => installer.Install(null, null, default).AsTask());
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => installer.Install(null, null, false, default).AsTask());
|
||||
|
||||
var byondVersion = new EngineVersion
|
||||
{
|
||||
@@ -98,10 +98,10 @@ namespace Tgstation.Server.Host.Components.Engine.Tests
|
||||
Version = new Version(123, 252345),
|
||||
};
|
||||
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => installer.Install(byondVersion, null, default).AsTask());
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => installer.Install(byondVersion, null, false, default).AsTask());
|
||||
|
||||
byondVersion.Version = new Version(511, 1385);
|
||||
await installer.Install(byondVersion, FakePath, default);
|
||||
await installer.Install(byondVersion, FakePath, false, default);
|
||||
|
||||
mockPostWriteHandler.Verify(x => x.HandleWrite(It.IsAny<string>()), Times.Exactly(4));
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace Tgstation.Server.Tests
|
||||
if (byondInstaller is WindowsByondInstaller)
|
||||
typeof(WindowsByondInstaller).GetField("installedDirectX", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(byondInstaller, true);
|
||||
|
||||
await byondInstaller.Install(engineVersion, tempPath, default);
|
||||
await byondInstaller.Install(engineVersion, tempPath, false, default);
|
||||
|
||||
var binPath = (string)typeof(ByondInstallerBase).GetField("ByondBinPath", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
var ddNameFunc = installerType.GetMethod("GetDreamDaemonName", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
Reference in New Issue
Block a user