From 1ba914afeebc7bc176079c56cc1035f54d55723e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 5 Jul 2020 12:00:55 -0400 Subject: [PATCH] Adds the PosixWatchdog - Test BasicWatchdog in Sqlite travis job - Rename UseBasicWatchdogOnWindows to UseBasicWatchdog - Inline one use of DatabaseContextExtensions in DmbFactory - Rename WindowsSwappableDmbProvider to SwappableDmbProvider - Fix DreamDaemonController returning the wrong ActiveCompileJob - Re-enable disabled watchdog tests --- .travis.yml | 3 +- .../Components/Deployment/DmbFactory.cs | 9 +- ...DmbProvider.cs => SwappableDmbProvider.cs} | 10 +- .../Components/Watchdog/BasicWatchdog.cs | 2 +- .../Components/Watchdog/PosixWatchdog.cs | 121 ++++++++++++++++++ .../Watchdog/PosixWatchdogFactory.cs | 78 +++++++++++ .../Components/Watchdog/WatchdogBase.cs | 2 + .../Components/Watchdog/WindowsWatchdog.cs | 53 ++++---- .../Watchdog/WindowsWatchdogFactory.cs | 10 +- .../Configuration/GeneralConfiguration.cs | 4 +- .../Controllers/DreamDaemonController.cs | 2 +- src/Tgstation.Server.Host/Core/Application.cs | 23 +++- .../Extensions/DatabaseContextExtensions.cs | 39 ------ src/Tgstation.Server.Host/appsettings.json | 2 +- .../Instance/WatchdogTest.cs | 6 +- 15 files changed, 274 insertions(+), 90 deletions(-) rename src/Tgstation.Server.Host/Components/Deployment/{WindowsSwappableDmbProvider.cs => SwappableDmbProvider.cs} (83%) create mode 100644 src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs create mode 100644 src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs delete mode 100644 src/Tgstation.Server.Host/Extensions/DatabaseContextExtensions.cs diff --git a/.travis.yml b/.travis.yml index e64a30f21f..0c495acc39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,10 @@ jobs: - DockerBuild=false - DMAPI=false - CONFIG=Release + - General__UseBasicWatchdog=true - TGS4_TEST_DATABASE_TYPE=Sqlite - TGS4_TEST_CONNECTION_STRING="Data Source=TravisTestDB.sqlite3;Mode=ReadWriteCreate" - name: "Sqlite Integration Test" + name: "Sqlite & BasicWatchdog Integration Test" language: csharp mono: none dotnet: 3.1 diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index 41a532235c..8754f58c19 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; @@ -173,7 +172,11 @@ namespace Tgstation.Server.Host.Components.Deployment await databaseContextFactory.UseContext(async (db) => { cj = await db - .MostRecentCompletedCompileJobOrDefault(instance, cancellationToken) + .CompileJobs + .AsQueryable() + .Where(x => x.Job.Instance.Id == instance.Id) + .OrderByDescending(x => x.Job.StoppedAt) + .FirstOrDefaultAsync(cancellationToken) .ConfigureAwait(false); }) .ConfigureAwait(false); @@ -322,7 +325,7 @@ namespace Tgstation.Server.Host.Components.Deployment .ToList(); }).ConfigureAwait(false); - jobUidsToNotErase.Add(WindowsSwappableDmbProvider.LiveGameDirectory); + jobUidsToNotErase.Add(SwappableDmbProvider.LiveGameDirectory); logger.LogTrace("We will not clean the following directories: {0}", String.Join(", ", jobUidsToNotErase)); diff --git a/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs similarity index 83% rename from src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs rename to src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs index eeab223e50..2c9c589f8e 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs @@ -7,9 +7,9 @@ using Tgstation.Server.Host.Models; namespace Tgstation.Server.Host.Components.Deployment { /// - /// A windows that uses symlinks. + /// A that uses symlinks. /// - sealed class WindowsSwappableDmbProvider : IDmbProvider + sealed class SwappableDmbProvider : IDmbProvider { /// /// The directory where the is symlinked to. @@ -41,12 +41,12 @@ namespace Tgstation.Server.Host.Components.Deployment readonly ISymlinkFactory symlinkFactory; /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// The value of . /// The value of . /// The value of . - public WindowsSwappableDmbProvider(IDmbProvider baseProvider, IIOManager ioManager, ISymlinkFactory symlinkFactory) + public SwappableDmbProvider(IDmbProvider baseProvider, IIOManager ioManager, ISymlinkFactory symlinkFactory) { this.baseProvider = baseProvider ?? throw new ArgumentNullException(nameof(baseProvider)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); @@ -60,7 +60,7 @@ namespace Tgstation.Server.Host.Components.Deployment public void KeepAlive() => baseProvider.KeepAlive(); /// - /// Make the active by replacing the live link with our . + /// Make the active by replacing the live link with our . /// /// The for the operation. /// A representing the running operation. diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index c26ea86502..e6fd0777e0 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -174,7 +174,7 @@ namespace Tgstation.Server.Host.Components.Watchdog protected sealed override ISessionController GetActiveController() => Server; /// - protected sealed override async Task InitControllers( + protected override async Task InitControllers( Task chatTask, ReattachInformation reattachInfo, CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs new file mode 100644 index 0000000000..09ffe48904 --- /dev/null +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -0,0 +1,121 @@ +using Microsoft.Extensions.Logging; +using System.Threading; +using System.Threading.Tasks; +using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.Components.Events; +using Tgstation.Server.Host.Components.Session; +using Tgstation.Server.Host.Core; +using Tgstation.Server.Host.Database; +using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.Jobs; + +namespace Tgstation.Server.Host.Components.Watchdog +{ + /// + /// A variant of the that works on POSIX systems. + /// + sealed class PosixWatchdog : WindowsWatchdog + { + /// + /// If the swappable game directory is currently a rename of the compile job. + /// + bool directoryHardLinked; + + /// + /// Initializes a new instance of the . + /// + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The pointing to the game directory for the .. + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The autostart value for the . + public PosixWatchdog( + IChatManager chat, + ISessionControllerFactory sessionControllerFactory, + IDmbFactory dmbFactory, + IReattachInfoHandler reattachInfoHandler, + IDatabaseContextFactory databaseContextFactory, + IJobManager jobManager, + IServerControl serverControl, + IAsyncDelayer asyncDelayer, + IIOManager diagnosticsIOManager, + IEventConsumer eventConsumer, + IIOManager gameIOManager, + ISymlinkFactory symlinkFactory, + ILogger logger, + DreamDaemonLaunchParameters initialLaunchParameters, + Api.Models.Instance instance, + bool autoStart) + : base( + chat, + sessionControllerFactory, + dmbFactory, + reattachInfoHandler, + databaseContextFactory, + jobManager, + serverControl, + asyncDelayer, + diagnosticsIOManager, + eventConsumer, + gameIOManager, + symlinkFactory, + logger, + initialLaunchParameters, + instance, + autoStart) + { } + + /// + protected override async Task InitialLink(SwappableDmbProvider swappableDmbProvider, CancellationToken cancellationToken) + { + // Instead of symlinking to begin with we actually rename the directory + Logger.LogTrace("Hard linking compile job..."); + await GameIOManager.MoveDirectory( + swappableDmbProvider.CompileJob.DirectoryName.ToString(), + swappableDmbProvider.Directory, + cancellationToken) + .ConfigureAwait(false); + directoryHardLinked = true; + } + + /// + protected override async Task InitControllers(Task chatTask, ReattachInformation reattachInfo, CancellationToken cancellationToken) + { + try + { + await base.InitControllers(chatTask, reattachInfo, cancellationToken).ConfigureAwait(false); + } + finally + { + // Then we move it back and apply the symlink + if (directoryHardLinked) + { + Logger.LogTrace("Unhardlinking compile job..."); + Server?.Suspend(); + await GameIOManager.MoveDirectory( + ActiveSwappable.Directory, + ActiveSwappable.CompileJob.DirectoryName.ToString(), + default) + .ConfigureAwait(false); + directoryHardLinked = false; + } + } + + await ActiveSwappable.MakeActive(cancellationToken).ConfigureAwait(false); + Server.Resume(); + } + } +} diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs new file mode 100644 index 0000000000..02341d91fb --- /dev/null +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs @@ -0,0 +1,78 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.Components.Events; +using Tgstation.Server.Host.Components.Session; +using Tgstation.Server.Host.Configuration; +using Tgstation.Server.Host.Core; +using Tgstation.Server.Host.Database; +using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.Jobs; + +namespace Tgstation.Server.Host.Components.Watchdog +{ + /// + /// for creating s. + /// + sealed class PosixWatchdogFactory : WindowsWatchdogFactory + { + /// + /// Initializes a new instance of the . + /// + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for for the . + public PosixWatchdogFactory( + IServerControl serverControl, + ILoggerFactory loggerFactory, + IDatabaseContextFactory databaseContextFactory, + IJobManager jobManager, + IAsyncDelayer asyncDelayer, + ISymlinkFactory symlinkFactory, + IOptions generalConfigurationOptions) + : base( + serverControl, + loggerFactory, + databaseContextFactory, + jobManager, + asyncDelayer, + symlinkFactory, + generalConfigurationOptions) + { } + + /// + public override IWatchdog CreateWatchdog( + IChatManager chat, + IDmbFactory dmbFactory, + IReattachInfoHandler reattachInfoHandler, + ISessionControllerFactory sessionControllerFactory, + IIOManager gameIOManager, + IIOManager diagnosticsIOManager, + IEventConsumer eventConsumer, + Api.Models.Instance instance, + DreamDaemonSettings settings) + => new PosixWatchdog( + chat, + sessionControllerFactory, + dmbFactory, + reattachInfoHandler, + DatabaseContextFactory, + JobManager, + ServerControl, + AsyncDelayer, + diagnosticsIOManager, + eventConsumer, + gameIOManager, + SymlinkFactory, + LoggerFactory.CreateLogger(), + settings, + instance, + settings.AutoStart.Value); + } +} diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index d25458735b..2142835fe8 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -236,6 +236,8 @@ namespace Tgstation.Server.Host.Components.Watchdog restartRegistration.Dispose(); throw; } + + Logger.LogTrace("Created watchdog"); } /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index aa59fc3d35..53c5df8421 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -15,14 +15,19 @@ using Tgstation.Server.Host.Jobs; namespace Tgstation.Server.Host.Components.Watchdog { /// - /// A version of the that, instead of killing servers for updates, uses the wonders of symlinks to swap out changes without killing DreamDaemon. + /// A that, instead of killing servers for updates, uses the wonders of symlinks to swap out changes without killing DreamDaemon. /// - sealed class WindowsWatchdog : BasicWatchdog + class WindowsWatchdog : BasicWatchdog { + /// + /// The for . + /// + protected SwappableDmbProvider ActiveSwappable { get; private set; } + /// /// The for the pointing to the Game directory. /// - readonly IIOManager gameIOManager; + protected IIOManager GameIOManager { get; } /// /// The for the . @@ -30,14 +35,9 @@ namespace Tgstation.Server.Host.Components.Watchdog readonly ISymlinkFactory symlinkFactory; /// - /// The for . + /// The active for . /// - WindowsSwappableDmbProvider activeSwappable; - - /// - /// The active for . - /// - WindowsSwappableDmbProvider pendingSwappable; + SwappableDmbProvider pendingSwappable; /// /// The the was started with. @@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the . /// The for the . /// The for the . - /// The value of . + /// The value of . /// The value of . /// The for the . /// The for the . @@ -97,7 +97,7 @@ namespace Tgstation.Server.Host.Components.Watchdog { try { - this.gameIOManager = gameIOManager ?? throw new ArgumentNullException(nameof(gameIOManager)); + GameIOManager = gameIOManager ?? throw new ArgumentNullException(nameof(gameIOManager)); this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); } catch @@ -113,7 +113,7 @@ namespace Tgstation.Server.Host.Components.Watchdog base.DisposeAndNullControllersImpl(); // If we reach this point, we can guarantee PrepServerForLaunch will be called before starting again. - activeSwappable = null; + ActiveSwappable = null; pendingSwappable?.Dispose(); pendingSwappable = null; @@ -128,7 +128,7 @@ namespace Tgstation.Server.Host.Components.Watchdog { Logger.LogTrace("Replacing activeSwappable with pendingSwappable..."); Server.ReplaceDmbProvider(pendingSwappable); - activeSwappable = pendingSwappable; + ActiveSwappable = pendingSwappable; pendingSwappable = null; } else @@ -154,11 +154,11 @@ namespace Tgstation.Server.Host.Components.Watchdog return; } - WindowsSwappableDmbProvider windowsProvider = null; + SwappableDmbProvider windowsProvider = null; bool suspended = false; try { - windowsProvider = new WindowsSwappableDmbProvider(compileJobProvider, gameIOManager, symlinkFactory); + windowsProvider = new SwappableDmbProvider(compileJobProvider, GameIOManager, symlinkFactory); Logger.LogDebug("Swapping to compile job {0}...", windowsProvider.CompileJob.Id); try @@ -190,9 +190,9 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) + protected sealed override async Task PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) { - if(activeSwappable != null) + if(ActiveSwappable != null) throw new InvalidOperationException("Expected activeSwappable to be null!"); if(startupDmbProvider != null) throw new InvalidOperationException("Expected startupDmbProvider to be null!"); @@ -202,21 +202,30 @@ namespace Tgstation.Server.Host.Components.Watchdog // Add another lock to the startup DMB because it'll be used throughout the lifetime of the watchdog startupDmbProvider = await DmbFactory.FromCompileJob(dmbToUse.CompileJob, cancellationToken).ConfigureAwait(false); - activeSwappable = pendingSwappable ?? new WindowsSwappableDmbProvider(dmbToUse, gameIOManager, symlinkFactory); + ActiveSwappable = pendingSwappable ?? new SwappableDmbProvider(dmbToUse, GameIOManager, symlinkFactory); pendingSwappable = null; try { - await activeSwappable.MakeActive(cancellationToken).ConfigureAwait(false); + await InitialLink(ActiveSwappable, cancellationToken).ConfigureAwait(false); } catch { // We won't worry about disposing activeSwappable here as we can't dispose dmbToUse here. - activeSwappable = null; + ActiveSwappable = null; throw; } - return activeSwappable; + return ActiveSwappable; } + + /// + /// Create the initial link to the live game directory. + /// + /// The in use. + /// The for the operation. + /// A representing the running operation. + protected virtual Task InitialLink(SwappableDmbProvider swappableDmbProvider, CancellationToken cancellationToken) + => swappableDmbProvider.MakeActive(cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs index df48c507a5..64222b1565 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs @@ -17,12 +17,12 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// for creating s. /// - sealed class WindowsWatchdogFactory : WatchdogFactory + class WindowsWatchdogFactory : WatchdogFactory { /// /// The for the . /// - readonly ISymlinkFactory symlinkFactory; + protected ISymlinkFactory SymlinkFactory { get; } /// /// Initializes a new instance of the . @@ -32,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the . /// The for the . /// The for the . - /// The value of . + /// The value of . /// The for for the . public WindowsWatchdogFactory( IServerControl serverControl, @@ -50,7 +50,7 @@ namespace Tgstation.Server.Host.Components.Watchdog asyncDelayer, generalConfigurationOptions) { - this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); + SymlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); } /// @@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.Components.Watchdog diagnosticsIOManager, eventConsumer, gameIOManager, - symlinkFactory, + SymlinkFactory, LoggerFactory.CreateLogger(), settings, instance, diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index 0ed129618a..69d5ec1b30 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -83,9 +83,9 @@ namespace Tgstation.Server.Host.Configuration public uint RestartTimeout { get; set; } = DefaultRestartTimeout; /// - /// If the should not be used if it is available. + /// If the should be preferred. /// - public bool UseBasicWatchdogOnWindows { get; set; } + public bool UseBasicWatchdog { get; set; } /// /// Initializes a new instance of the . diff --git a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs index c33f04e713..aa66421cc8 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs @@ -142,7 +142,7 @@ namespace Tgstation.Server.Host.Controllers if (revision) { var latestCompileJob = instance.LatestCompileJob(); - result.ActiveCompileJob = ((instance.Watchdog.Status == WatchdogStatus.Offline + result.ActiveCompileJob = ((instance.Watchdog.Status != WatchdogStatus.Offline ? dd.ActiveCompileJob : latestCompileJob) ?? latestCompileJob) ?.ToApi(); diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 2920cbaf2f..0b21fb8cc5 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -251,11 +251,7 @@ namespace Tgstation.Server.Host.Core // configure platform specific services if (postSetupServices.PlatformIdentifier.IsWindows) { - if (postSetupServices.GeneralConfiguration.UseBasicWatchdogOnWindows) - services.AddSingleton(); - else - services.AddSingleton(); - + AddWatchdog(services, postSetupServices); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); @@ -268,7 +264,7 @@ namespace Tgstation.Server.Host.Core } else { - services.AddSingleton(); + AddWatchdog(services, postSetupServices); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); @@ -303,6 +299,21 @@ namespace Tgstation.Server.Host.Core services.AddSingleton(x => x.GetRequiredService()); } + /// + /// Adds the implementation. + /// + /// The child for the current system. + /// The to configure. + /// The to use. + static void AddWatchdog(IServiceCollection services, IPostSetupServices postSetupServices) + where TSystemWatchdogFactory : class, IWatchdogFactory + { + if (postSetupServices.GeneralConfiguration.UseBasicWatchdog) + services.AddSingleton(); + else + services.AddSingleton(); + } + /// protected override void ConfigureHostedService(IServiceCollection services) => services.AddSingleton(x => x.GetRequiredService()); diff --git a/src/Tgstation.Server.Host/Extensions/DatabaseContextExtensions.cs b/src/Tgstation.Server.Host/Extensions/DatabaseContextExtensions.cs deleted file mode 100644 index 2aaf72f6aa..0000000000 --- a/src/Tgstation.Server.Host/Extensions/DatabaseContextExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Models; - -namespace Tgstation.Server.Host.Extensions -{ - /// - /// Extensions for the . - /// - static class DatabaseContextExtensions - { - /// - /// Get the most recent for a given from a given . - /// - /// The . - /// The to search for s. - /// The for the operation. - /// A resulting in the most recent associated with the given from the . - public static Task MostRecentCompletedCompileJobOrDefault( - this IDatabaseContext databaseContext, - Api.Models.Instance instance, - CancellationToken cancellationToken) - { - if (databaseContext == null) - throw new ArgumentNullException(nameof(databaseContext)); - - return databaseContext - .CompileJobs - .AsQueryable() - .Where(x => x.Job.Instance.Id == instance.Id) - .OrderByDescending(x => x.Job.StoppedAt) - .FirstOrDefaultAsync(cancellationToken); - } - } -} diff --git a/src/Tgstation.Server.Host/appsettings.json b/src/Tgstation.Server.Host/appsettings.json index 0802590406..49409225a3 100644 --- a/src/Tgstation.Server.Host/appsettings.json +++ b/src/Tgstation.Server.Host/appsettings.json @@ -6,7 +6,7 @@ "ByondTopicTimeout": 5000, "RestartTimeout": 60000, "ApiPort": 5000, - "UseBasicWatchdogOnWindows": false, + "UseBasicWatchdog": false, "UserLimit": 100, "InstanceLimit": 10, "ValidInstancePaths": null diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index a568f58a7c..4155f3c1a3 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -59,10 +59,8 @@ namespace Tgstation.Server.Tests.Instance Version = ByondTest.TestVersion }, cancellationToken); - // await RunLongRunningTestThenUpdate(cancellationToken); - // await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); - // Remove this deploy when the above tests are reenabled - await DeployTestDme("LongRunning/long_running_test", DreamDaemonSecurity.Trusted, cancellationToken); + await RunLongRunningTestThenUpdate(cancellationToken); + await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); await RunHeartbeatTest(cancellationToken);