From c660a56de1b0844099731fae1f8bdd7c7d9b6161 Mon Sep 17 00:00:00 2001 From: Kirill Ivlev <102740624+kirill-ivlev@users.noreply.github.com> Date: Thu, 18 Jul 2024 20:26:57 +0400 Subject: [PATCH] Revert "Allow running agent in debugging mode for specific node task (#4838)" (#4898) This reverts commit 3f8844537d28c509df921b6a3c604353664b9caa. --- src/Agent.Listener/Agent.cs | 7 ------- src/Agent.Listener/CommandLine/RunAgent.cs | 3 --- src/Agent.Listener/CommandSettings.cs | 5 ----- src/Agent.Sdk/Knob/AgentKnobs.cs | 6 ------ src/Agent.Worker/Handlers/NodeHandler.cs | 15 --------------- .../ConfigurationStore.cs | 3 --- .../Constants.cs | 1 - 7 files changed, 40 deletions(-) diff --git a/src/Agent.Listener/Agent.cs b/src/Agent.Listener/Agent.cs index 37a5ea33da..f1bdd0f80f 100644 --- a/src/Agent.Listener/Agent.cs +++ b/src/Agent.Listener/Agent.cs @@ -216,13 +216,6 @@ public async Task ExecuteCommand(CommandSettings command) Trace.Info($"Set agent startup type - {startType}"); HostContext.StartupType = startType; - bool debugModeEnabled = command.GetDebugMode(); - settings.DebugMode = debugModeEnabled; - store.SaveSettings(settings); - if (debugModeEnabled) - { - Trace.Warning("Agent is running in debug mode, don't use it in production"); - } if (PlatformUtil.RunningOnWindows) { if (store.IsAutoLogonConfigured()) diff --git a/src/Agent.Listener/CommandLine/RunAgent.cs b/src/Agent.Listener/CommandLine/RunAgent.cs index e6ea5b8fd7..4261f0db04 100644 --- a/src/Agent.Listener/CommandLine/RunAgent.cs +++ b/src/Agent.Listener/CommandLine/RunAgent.cs @@ -18,8 +18,5 @@ public class RunAgent : BaseCommand [Option(Constants.Agent.CommandLine.Args.StartupType)] public string StartupType { get; set; } - - [Option(Constants.Agent.CommandLine.Flags.DebugMode)] - public bool DebugMode { get; set; } } } diff --git a/src/Agent.Listener/CommandSettings.cs b/src/Agent.Listener/CommandSettings.cs index ecd74280ea..0407937c37 100644 --- a/src/Agent.Listener/CommandSettings.cs +++ b/src/Agent.Listener/CommandSettings.cs @@ -550,11 +550,6 @@ public bool GetRunOnce() TestFlag(Run?.RunOnce, Constants.Agent.CommandLine.Flags.Once); } - public bool GetDebugMode() - { - return TestFlag(Run?.DebugMode, Constants.Agent.CommandLine.Flags.DebugMode); - } - public bool GetDeploymentPool() { return TestFlag(Configure?.DeploymentPool, Constants.Agent.CommandLine.Flags.DeploymentPool); diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index 5e469fba9a..b7c2b8bfa1 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -213,12 +213,6 @@ public class AgentKnobs new EnvironmentKnobSource("VSTSAGENT_TRACE"), new BuiltInDefaultKnobSource(string.Empty)); - public static readonly Knob DebugTask = new Knob( - nameof(DebugTask), - "If the agent executes a task which ID or name matches the value provided, it will run the task so that it will wait for debugger to attach", - new EnvironmentKnobSource("VSTSAGENT_DEBUG_TASK"), - new BuiltInDefaultKnobSource(string.Empty)); - public static readonly Knob DumpJobEventLogs = new Knob( nameof(DumpJobEventLogs), "If true, dump event viewer logs", diff --git a/src/Agent.Worker/Handlers/NodeHandler.cs b/src/Agent.Worker/Handlers/NodeHandler.cs index 7be1cb6c4e..8e7d21fdc3 100644 --- a/src/Agent.Worker/Handlers/NodeHandler.cs +++ b/src/Agent.Worker/Handlers/NodeHandler.cs @@ -224,21 +224,6 @@ public async Task RunAsync() var sigtermTimeout = TimeSpan.FromMilliseconds(AgentKnobs.ProccessSigtermTimeout.GetValue(ExecutionContext).AsInt()); var useGracefulShutdown = AgentKnobs.UseGracefulProcessShutdown.GetValue(ExecutionContext).AsBoolean(); - var configStore = HostContext.GetService(); - var agentSettings = configStore.GetSettings(); - if (agentSettings.DebugMode) - { - var debugTask = AgentKnobs.DebugTask.GetValue(ExecutionContext).AsString(); - if (!string.IsNullOrEmpty(debugTask)) - { - if (string.Equals(Task?.Id.ToString("D"), debugTask, StringComparison.OrdinalIgnoreCase) || string.Equals(Task?.Name, debugTask, StringComparison.OrdinalIgnoreCase)) - { - arguments = $"--inspect-brk {arguments}"; - } - } - } - - try { // Execute the process. Exit code 0 should always be returned. diff --git a/src/Microsoft.VisualStudio.Services.Agent/ConfigurationStore.cs b/src/Microsoft.VisualStudio.Services.Agent/ConfigurationStore.cs index b39f04bc76..92d6f6c2a8 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/ConfigurationStore.cs +++ b/src/Microsoft.VisualStudio.Services.Agent/ConfigurationStore.cs @@ -132,9 +132,6 @@ public string Fingerprint [DataMember(EmitDefaultValue = false)] public int MaxDedupParallelism { get; set; } - - [DataMember(EmitDefaultValue = false)] - public bool DebugMode { get; set; } } [DataContract] diff --git a/src/Microsoft.VisualStudio.Services.Agent/Constants.cs b/src/Microsoft.VisualStudio.Services.Agent/Constants.cs index 3b041e12b0..2842370879 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/Constants.cs +++ b/src/Microsoft.VisualStudio.Services.Agent/Constants.cs @@ -225,7 +225,6 @@ public static class Flags public const string NoRestart = "norestart"; public const string LaunchBrowser = "launchbrowser"; public const string Once = "once"; - public const string DebugMode = "debug"; public const string RunAsAutoLogon = "runasautologon"; public const string RunAsService = "runasservice"; public const string PreventServiceStart = "preventservicestart";