diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs index 45040690..9b56e3af 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs @@ -5,10 +5,10 @@ namespace AIStudio.Tools.PluginSystem; public static partial class PluginFactory { - public static async Task<(bool Success, EntityTagHeaderValue? ETag)> DetermineConfigPluginETagAsync(Guid configPlugId, string configServerUrl, CancellationToken cancellationToken = default) + public static async Task<(bool Success, EntityTagHeaderValue? ETag, string? Issue)> DetermineConfigPluginETagAsync(Guid configPlugId, string configServerUrl, CancellationToken cancellationToken = default) { if(configPlugId == Guid.Empty || string.IsNullOrWhiteSpace(configServerUrl)) - return (false, null); + return (false, null, "Configuration ID or server URL is missing."); try { @@ -21,15 +21,15 @@ public static partial class PluginFactory if (!response.IsSuccessStatusCode) { LOG.LogError($"Failed to determine the ETag for configuration plugin '{configPlugId}'. HTTP Status: {response.StatusCode}"); - return (false, null); + return (false, null, $"HTTP status: {response.StatusCode}"); } - return (true, response.Headers.ETag); + return (true, response.Headers.ETag, null); } catch (Exception e) { LOG.LogError(e, "An error occurred while determining the ETag for the configuration plugin."); - return (false, null); + return (false, null, e.Message); } } diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Remove.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Remove.cs index 888a0aa2..0a7b4a12 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Remove.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Remove.cs @@ -4,6 +4,8 @@ namespace AIStudio.Tools.PluginSystem; public static partial class PluginFactory { + private const string REASON_NO_LONGER_REFERENCED = "no longer referenced by active enterprise environments"; + public static void RemoveUnreferencedManagedConfigurationPlugins(ISet activeConfigurationIds) { if (!IsInitialized) @@ -42,15 +44,15 @@ public static partial class PluginFactory } foreach (var pluginId in pluginIdsToRemove) - RemovePluginAsync(pluginId); + RemovePluginAsync(pluginId, REASON_NO_LONGER_REFERENCED); } - private static void RemovePluginAsync(Guid pluginId) + private static void RemovePluginAsync(Guid pluginId, string reason) { if (!IsInitialized) return; - LOG.LogWarning("Try to remove plugin with ID: '{PluginId}'.", pluginId); + LOG.LogWarning("Removing plugin with ID '{PluginId}'. Reason: {Reason}.", pluginId, reason); // // Remove the plugin from the available plugins list: @@ -59,14 +61,14 @@ public static partial class PluginFactory if (availablePluginToRemove != null) AVAILABLE_PLUGINS.Remove(availablePluginToRemove); else - LOG.LogWarning("No available plugin found with ID: '{PluginId}'.", pluginId); + LOG.LogWarning("No available plugin found with ID '{PluginId}' while removing plugin. Reason: {Reason}.", pluginId, reason); // // Remove the plugin from the running plugins list: // var runningPluginToRemove = RUNNING_PLUGINS.FirstOrDefault(p => p.Id == pluginId); if (runningPluginToRemove == null) - LOG.LogWarning("No running plugin found with ID: '{PluginId}'.", pluginId); + LOG.LogWarning("No running plugin found with ID '{PluginId}' while removing plugin. Reason: {Reason}.", pluginId, reason); else RUNNING_PLUGINS.Remove(runningPluginToRemove); @@ -75,7 +77,7 @@ public static partial class PluginFactory // DeleteConfigurationPluginDirectory(pluginId); - LOG.LogInformation("Plugin with ID='{PluginId}' removed successfully.", pluginId); + LOG.LogInformation("Plugin with ID '{PluginId}' removed successfully. Reason: {Reason}.", pluginId, reason); } private static bool? ReadDeployFlagFromPluginFile(string pluginDirectory) diff --git a/app/MindWork AI Studio/Tools/Services/EnterpriseEnvironmentService.cs b/app/MindWork AI Studio/Tools/Services/EnterpriseEnvironmentService.cs index badaf5ed..0d2f2aa1 100644 --- a/app/MindWork AI Studio/Tools/Services/EnterpriseEnvironmentService.cs +++ b/app/MindWork AI Studio/Tools/Services/EnterpriseEnvironmentService.cs @@ -79,7 +79,7 @@ public sealed class EnterpriseEnvironmentService(ILogger