diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs
index 7850f9e5e5..cd0e855151 100644
--- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs
+++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs
@@ -776,14 +776,14 @@ namespace Tgstation.Server.Host.Swarm
/// A resulting in the .
async ValueTask PrepareUpdateImpl(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken)
{
+ var version = updateRequest.UpdateVersion!;
if (!SwarmMode)
{
// we still need an active update operation for the TargetVersion
- updateOperation = new SwarmUpdateOperation(updateRequest.UpdateVersion);
+ updateOperation = new SwarmUpdateOperation(version);
return SwarmPrepareResult.SuccessProviderNotRequired;
}
- var version = updateRequest.UpdateVersion;
var initiator = initiatorProvider != null;
logger.LogTrace("PrepareUpdateImpl {version}...", version);
@@ -868,6 +868,12 @@ namespace Tgstation.Server.Host.Swarm
return SwarmPrepareResult.Failure;
}
+ if (updateRequest.DownloadTickets == null)
+ {
+ logger.LogError("Missing download tickets in update request!");
+ return SwarmPrepareResult.Failure;
+ }
+
if (!updateRequest.DownloadTickets.TryGetValue(swarmConfiguration.Identifier!, out var ticket))
{
logger.Log(
@@ -970,7 +976,7 @@ namespace Tgstation.Server.Host.Swarm
}
// The initiator node obviously doesn't create a ticket for itself
- else if (!weAreInitiator && updateRequest.DownloadTickets.Count != currentUpdateOperation.InvolvedServers.Count - 1)
+ else if (!weAreInitiator && updateRequest.DownloadTickets!.Count != currentUpdateOperation.InvolvedServers.Count - 1)
{
logger.LogWarning(
"Aborting update, {receivedTickets} download tickets were provided but there are {nodesToUpdate} nodes in the swarm that require the package!",
@@ -982,7 +988,7 @@ namespace Tgstation.Server.Host.Swarm
var downloadTicketDictionary = weAreInitiator
? await CreateDownloadTickets(initiatorProvider!, currentUpdateOperation.InvolvedServers, cancellationToken)
- : updateRequest.DownloadTickets;
+ : updateRequest.DownloadTickets!;
var sourceNode = weAreInitiator
? swarmConfiguration.Identifier
@@ -998,17 +1004,18 @@ namespace Tgstation.Server.Host.Swarm
.Select(node =>
{
// only send the necessary ticket to each node from the controller
- Dictionary localTicketDictionary;
+ Dictionary? localTicketDictionary;
var nodeId = node.Identifier!;
- if (!downloadTicketDictionary.TryGetValue(nodeId, out var ticket)
- && nodeId != sourceNode)
+ if (nodeId == sourceNode)
+ localTicketDictionary = null;
+ else if (!downloadTicketDictionary.TryGetValue(nodeId, out var ticket))
{
logger.LogError("Missing download ticket for node {missingNodeId}!", nodeId);
anyFailed = true;
return null;
}
else
- localTicketDictionary = new Dictionary
+ localTicketDictionary = new Dictionary
{
{ nodeId, ticket },
};
diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs
index a0d7b0fe5c..958a8f5afb 100644
--- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs
+++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs
@@ -4,8 +4,6 @@ using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Response;
-#nullable disable
-
namespace Tgstation.Server.Host.Swarm
{
///
@@ -17,17 +15,17 @@ namespace Tgstation.Server.Host.Swarm
/// The TGS to update to.
///
[Required]
- public Version UpdateVersion { get; init; }
+ public Version? UpdateVersion { get; init; }
///
/// The of the node to download the update package from.
///
[Required]
- public string SourceNode { get; init; }
+ public string? SourceNode { get; init; }
///
/// The map of s to s for retrieving the update package from the initiating server.
///
- public Dictionary DownloadTickets { get; init; }
+ public Dictionary? DownloadTickets { get; init; }
}
}