From 9ba8b94e2ccbf477de3b5e7f4ab853e1a1a781a9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 6 May 2025 18:52:09 -0400 Subject: [PATCH 1/6] Add API for queuing text deployment messages --- .../Components/Chat/ChatManager.cs | 54 +++++++++++-------- .../Components/Chat/IChatManager.cs | 6 +++ 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 5faa30dbd2..b6685b7460 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -351,28 +351,11 @@ namespace Tgstation.Server.Host.Components.Chat /// public void QueueWatchdogMessage(string message) - { - ArgumentNullException.ThrowIfNull(message); + => QueueMessageGeneric(mapping => mapping.IsWatchdogChannel, message); - message = String.Format(CultureInfo.InvariantCulture, "WD: {0}", message); - - if (!initialProviderConnectionsTask!.IsCompleted) - logger.LogTrace("Waiting for initial provider connections before sending watchdog message..."); - - // Reimplementing QueueMessage - QueueMessageInternal( - new MessageContent - { - Text = message, - }, - () => - { - // so it doesn't change while we're using it - lock (mappedChannels) - return mappedChannels.Where(x => x.Value.IsWatchdogChannel).Select(x => x.Key).ToList(); - }, - true); - } + /// + public void QueueDeploymentMessage(string message) + => QueueMessageGeneric(mapping => mapping.IsUpdatesChannel, message); /// public Func> QueueDeploymentMessage( @@ -1111,5 +1094,34 @@ namespace Tgstation.Server.Host.Components.Chat AddMessageTask(SendMessageTask()); } + + /// + /// Queues a message to a selected set of s. + /// + /// A for selecting the s to send to. + /// The message to send. + void QueueMessageGeneric(Predicate channelSelector, string message) + { + ArgumentNullException.ThrowIfNull(message); + + message = String.Format(CultureInfo.InvariantCulture, "WD: {0}", message); + + if (!initialProviderConnectionsTask!.IsCompleted) + logger.LogTrace("Waiting for initial provider connections before sending watchdog message..."); + + // Reimplementing QueueMessage + QueueMessageInternal( + new MessageContent + { + Text = message, + }, + () => + { + // so it doesn't change while we're using it + lock (mappedChannels) + return mappedChannels.Where(x => channelSelector(x.Value)).Select(x => x.Key).ToList(); + }, + true); + } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs index 669f21b305..2b2faf9496 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs @@ -57,6 +57,12 @@ namespace Tgstation.Server.Host.Components.Chat /// The message being sent. void QueueWatchdogMessage(string message); + /// + /// Queue a chat to configured deployment channels. + /// + /// The message being sent. + void QueueDeploymentMessage(string message); + /// /// Send the message for a deployment to configured deployment channels. /// From d5c3ddbd4ef216086ae72b0f3234d3a0f358d6ac Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 6 May 2025 18:53:18 -0400 Subject: [PATCH 2/6] Add a chat message when an automatic update fails due to a conflict --- src/Tgstation.Server.Host/Components/Instance.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index f0fd27f661..8957678a3e 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -531,7 +531,10 @@ namespace Tgstation.Server.Host.Components } } else if (preserveTestMerges) + { + Chat.QueueDeploymentMessage("Automatic update has failed due to a conflicting testmerge!"); throw new JobException(Api.Models.ErrorCode.InstanceUpdateTestMergeConflict); + } if (!preserveTestMerges) { From ac56e2c3fa8a96deb155d3ff6be4fd0a65390bd3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 6 May 2025 18:53:42 -0400 Subject: [PATCH 3/6] Version bump to 6.18.0 --- build/Version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Version.props b/build/Version.props index 394ff58026..7312268ed1 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 6.17.0 + 6.18.0 5.7.0 10.13.0 0.6.0 From 6384254cdc1a4531e32ee703dfc94af32855efd4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 6 May 2025 18:59:13 -0400 Subject: [PATCH 4/6] Fix bad prefix for auto-update fail message --- .../Components/Chat/ChatManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index b6685b7460..4b42fb0a56 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -351,11 +351,11 @@ namespace Tgstation.Server.Host.Components.Chat /// public void QueueWatchdogMessage(string message) - => QueueMessageGeneric(mapping => mapping.IsWatchdogChannel, message); + => QueueMessageGeneric(mapping => mapping.IsWatchdogChannel, message, "WD"); /// public void QueueDeploymentMessage(string message) - => QueueMessageGeneric(mapping => mapping.IsUpdatesChannel, message); + => QueueMessageGeneric(mapping => mapping.IsUpdatesChannel, message, null); /// public Func> QueueDeploymentMessage( @@ -1100,14 +1100,18 @@ namespace Tgstation.Server.Host.Components.Chat /// /// A for selecting the s to send to. /// The message to send. - void QueueMessageGeneric(Predicate channelSelector, string message) + /// The optional prefix to the message to be sent. + void QueueMessageGeneric(Predicate channelSelector, string message, string prefix) { ArgumentNullException.ThrowIfNull(message); - message = String.Format(CultureInfo.InvariantCulture, "WD: {0}", message); + if (prefix != null) + { + message = $"{prefix}: {message}"; + } if (!initialProviderConnectionsTask!.IsCompleted) - logger.LogTrace("Waiting for initial provider connections before sending watchdog message..."); + logger.LogTrace("Waiting for initial provider connections before sending chat message..."); // Reimplementing QueueMessage QueueMessageInternal( From 1f4ac78d42a7231a444f79772932b12041be27bc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 7 May 2025 17:56:33 -0400 Subject: [PATCH 5/6] Fix nullable error --- src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 4b42fb0a56..abd5ef90c3 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -1101,7 +1101,7 @@ namespace Tgstation.Server.Host.Components.Chat /// A for selecting the s to send to. /// The message to send. /// The optional prefix to the message to be sent. - void QueueMessageGeneric(Predicate channelSelector, string message, string prefix) + void QueueMessageGeneric(Predicate channelSelector, string message, string? prefix) { ArgumentNullException.ThrowIfNull(message); From 721beaff68673573a387d66b4a0e4573e29fc352 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 9 May 2025 21:32:26 -0400 Subject: [PATCH 6/6] Fix conflicting name error --- src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 2 +- src/Tgstation.Server.Host/Components/Chat/IChatManager.cs | 2 +- src/Tgstation.Server.Host/Components/Instance.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index abd5ef90c3..2aeca4f8f3 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -354,7 +354,7 @@ namespace Tgstation.Server.Host.Components.Chat => QueueMessageGeneric(mapping => mapping.IsWatchdogChannel, message, "WD"); /// - public void QueueDeploymentMessage(string message) + public void QueueRawDeploymentMessage(string message) => QueueMessageGeneric(mapping => mapping.IsUpdatesChannel, message, null); /// diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs index 2b2faf9496..4f112afb69 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs @@ -61,7 +61,7 @@ namespace Tgstation.Server.Host.Components.Chat /// Queue a chat to configured deployment channels. /// /// The message being sent. - void QueueDeploymentMessage(string message); + void QueueRawDeploymentMessage(string message); /// /// Send the message for a deployment to configured deployment channels. diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 8957678a3e..37454b7dbc 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -532,7 +532,7 @@ namespace Tgstation.Server.Host.Components } else if (preserveTestMerges) { - Chat.QueueDeploymentMessage("Automatic update has failed due to a conflicting testmerge!"); + Chat.QueueRawDeploymentMessage("Automatic update has failed due to a conflicting testmerge!"); throw new JobException(Api.Models.ErrorCode.InstanceUpdateTestMergeConflict); }