diff --git a/source/Octopus.Manager.Tentacle/App.xaml.cs b/source/Octopus.Manager.Tentacle/App.xaml.cs index 998118e5d..2bdf703ce 100644 --- a/source/Octopus.Manager.Tentacle/App.xaml.cs +++ b/source/Octopus.Manager.Tentacle/App.xaml.cs @@ -12,6 +12,7 @@ using Octopus.Manager.Core.Shared.Shell; using Octopus.Manager.Core.Util; using Octopus.Manager.Tentacle.TentacleConfiguration; +using Octopus.Manager.Tentacle.TentacleConfiguration.TentacleManager; using Octopus.Shared.Configuration; using Octopus.Shared.Diagnostics; using Octopus.Shared.Internals.Options; @@ -91,10 +92,11 @@ void ReconfigureTentacleService(IApplicationInstanceStore applicationInstanceSto var instancesWithDefaultFirst = defaultInstance.Concat(instances.Except(defaultInstance).OrderBy(x => x.InstanceName)); foreach (var instance in instancesWithDefaultFirst) { - var service = new ServiceWatcher(instance.ApplicationName, instance.InstanceName, CommandLine.PathToTentacleExe()); + var model = new TentacleManagerModel(); + model.Load(instance); var isDefaultInstance = instance.InstanceName == ApplicationInstanceRecord.GetDefaultInstance(instance.ApplicationName); var title = isDefaultInstance ? "Reconfiguring Tentacle..." : $"Reconfiguring Tentacle {instance.InstanceName}..."; - RunProcessDialog.ShowDialog(MainWindow, service.GetReconfigureCommands(), title); + RunProcessDialog.ShowDialog(MainWindow, model.ServiceWatcher.GetReconfigureCommands(), title, model.LogsDirectory); } } diff --git a/source/Octopus.Manager.Tentacle/Octopus.Manager.Tentacle.csproj b/source/Octopus.Manager.Tentacle/Octopus.Manager.Tentacle.csproj index b9bfb91ec..eb660b2f1 100644 --- a/source/Octopus.Manager.Tentacle/Octopus.Manager.Tentacle.csproj +++ b/source/Octopus.Manager.Tentacle/Octopus.Manager.Tentacle.csproj @@ -128,11 +128,11 @@ ..\packages\Octopus.Diagnostics.1.0.11\lib\netstandard1.0\Octopus.Diagnostics.dll True - - ..\packages\Octopus.Manager.Core.3.13.9-tentsplit0048\lib\Octopus.Manager.Core.dll + + ..\packages\Octopus.Manager.Core.3.14.1-enh-showdbupgrad0062\lib\Octopus.Manager.Core.dll - - ..\packages\Octopus.Shared.3.14.0-beta0005\lib\Octopus.Shared.dll + + ..\packages\Octopus.Shared.3.14.1-enh-showdbupgrad0062\lib\Octopus.Shared.dll ..\packages\Octopus.Time.1.0.8\lib\netstandard1.0\Octopus.Time.dll diff --git a/source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/TentacleSetupWizardModel.cs b/source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/TentacleSetupWizardModel.cs index ff9970dbc..57c2ca34a 100644 --- a/source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/TentacleSetupWizardModel.cs +++ b/source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/TentacleSetupWizardModel.cs @@ -592,7 +592,6 @@ string[] SelectedTenantsArray public IEnumerable GenerateScript() { - var root = Path.GetFullPath(HomeDirectory); pathToConfig = Path.Combine(HomeDirectory, ((ApplicationInstanceRecord.GetDefaultInstance(applicationName) != InstanceName) ? "Tentacle-" + InstanceName : InstanceName) + ".config"); yield return Cli("create-instance").Argument("config", pathToConfig).Build(); @@ -600,7 +599,6 @@ public IEnumerable GenerateScript() yield return Cli("configure").Flag("reset-trust").Build(); var config = Cli("configure") - .Argument("home", root) .Argument("app", applicationInstallDirectory) .Argument("port", ListenPort) .Argument("noListen", IsTentacleActive.ToString()); diff --git a/source/Octopus.Manager.Tentacle/TentacleConfiguration/TentacleManager/TentacleManagerView.xaml.cs b/source/Octopus.Manager.Tentacle/TentacleConfiguration/TentacleManager/TentacleManagerView.xaml.cs index daf78e913..cde780852 100644 --- a/source/Octopus.Manager.Tentacle/TentacleConfiguration/TentacleManager/TentacleManagerView.xaml.cs +++ b/source/Octopus.Manager.Tentacle/TentacleConfiguration/TentacleManager/TentacleManagerView.xaml.cs @@ -83,24 +83,24 @@ void SetupTentacle(object sender, RoutedEventArgs e) void StartServiceClicked(object sender, EventArgs e) { - RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetStartCommands(), "Starting Tentacle service..."); + RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetStartCommands(), "Starting Tentacle service...", model.LogsDirectory); } void StopServiceClicked(object sender, EventArgs e) { - RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetStopCommands(), "Stopping Tentacle service..."); + RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetStopCommands(), "Stopping Tentacle service...", model.LogsDirectory); Refresh(); } void RestartServiceClicked(object sender, EventArgs e) { - RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetRestartCommands(), "Restarting Tentacle service..."); + RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetRestartCommands(), "Restarting Tentacle service...", model.LogsDirectory); Refresh(); } void RepairServiceClicked(object sender, EventArgs e) { - RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetRepairCommands(), "Reinstalling the Tentacle service..."); + RunProcessDialog.ShowDialog(Window.GetWindow(this), model.ServiceWatcher.GetRepairCommands(), "Reinstalling the Tentacle service...", model.LogsDirectory); } void ShowProxy(object sender, EventArgs e) diff --git a/source/Octopus.Manager.Tentacle/packages.config b/source/Octopus.Manager.Tentacle/packages.config index a8a482c62..075ff7f8d 100644 --- a/source/Octopus.Manager.Tentacle/packages.config +++ b/source/Octopus.Manager.Tentacle/packages.config @@ -18,8 +18,8 @@ - - + + diff --git a/source/Octopus.Tentacle.Tests/Commands/DeregisterMachineCommandFixture.cs b/source/Octopus.Tentacle.Tests/Commands/DeregisterMachineCommandFixture.cs index 4a372daf4..c50f4d033 100644 --- a/source/Octopus.Tentacle.Tests/Commands/DeregisterMachineCommandFixture.cs +++ b/source/Octopus.Tentacle.Tests/Commands/DeregisterMachineCommandFixture.cs @@ -6,6 +6,7 @@ using Octopus.Client; using Octopus.Client.Model; using Octopus.Diagnostics; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Security; using Octopus.Tentacle.Commands; @@ -50,7 +51,7 @@ public async Task ShouldNotContinueIfMultipleMatchesButAllowMultipleIsNotSupplie asyncRepository.Machines.FindByThumbprint(Arg.Any()) .ReturnsForAnyArgs(matchingMachines.AsTask()); - var result = Assert.Throws( async () => await Command.Deregister(asyncRepository)); + var result = Assert.Throws( async () => await Command.Deregister(asyncRepository)); Assert.That(result.Message.Equals(DeregisterMachineCommand.MultipleMatchErrorMsg)); } diff --git a/source/Octopus.Tentacle.Tests/Commands/ServerCommsCommandTest.cs b/source/Octopus.Tentacle.Tests/Commands/ServerCommsCommandTest.cs index 227f8c18a..bec9f52c2 100644 --- a/source/Octopus.Tentacle.Tests/Commands/ServerCommsCommandTest.cs +++ b/source/Octopus.Tentacle.Tests/Commands/ServerCommsCommandTest.cs @@ -5,6 +5,7 @@ using NSubstitute; using NUnit.Framework; using Octopus.Client.Model; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Internals.Options; using Octopus.Shared.Startup; @@ -78,7 +79,7 @@ static void Assert(OctopusServerConfiguration server, string thumbprint, Communi public void NoTrusts() { Action action = () => Execute(Thumb1, CommunicationStyle.TentaclePassive); - action.ShouldThrow() + action.ShouldThrow() .WithMessage("Before server communications can be modified, trust must be established with the configure command"); } @@ -98,7 +99,7 @@ public void AddActiveNoHost() { AddTrusts(Thumb1); Action action = () => Execute(Thumb1, CommunicationStyle.TentacleActive, null, "1234"); - action.ShouldThrow() + action.ShouldThrow() .WithMessage("Please provide either the server hostname or websocket address, e.g. --host=OCTOPUS"); } diff --git a/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj b/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj index 1b5d7667e..e3be9ad6f 100644 --- a/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj +++ b/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj @@ -128,7 +128,7 @@ True - ..\packages\Octopus.Shared.3.14.1-enh-sha256-ui0002\lib\Octopus.Shared.dll + ..\packages\Octopus.Shared.3.14.1-enh-showdbupgrad0062\lib\Octopus.Shared.dll ..\packages\Octopus.Time.1.0.8\lib\netstandard1.0\Octopus.Time.dll diff --git a/source/Octopus.Tentacle.Tests/packages.config b/source/Octopus.Tentacle.Tests/packages.config index c7ab581ce..92f85645e 100644 --- a/source/Octopus.Tentacle.Tests/packages.config +++ b/source/Octopus.Tentacle.Tests/packages.config @@ -42,7 +42,7 @@ - + diff --git a/source/Octopus.Tentacle/Commands/ConfigureCommand.cs b/source/Octopus.Tentacle/Commands/ConfigureCommand.cs index ac86b04a1..99cb4ba69 100644 --- a/source/Octopus.Tentacle/Commands/ConfigureCommand.cs +++ b/source/Octopus.Tentacle/Commands/ConfigureCommand.cs @@ -83,8 +83,6 @@ public ConfigureCommand( protected override void Start() { - base.Start(); - if (resetTrust) { log.Info("Removing all trusted Octopus servers..."); diff --git a/source/Octopus.Tentacle/Commands/DeregisterMachineCommand.cs b/source/Octopus.Tentacle/Commands/DeregisterMachineCommand.cs index fa3d57f9c..4daf39344 100644 --- a/source/Octopus.Tentacle/Commands/DeregisterMachineCommand.cs +++ b/source/Octopus.Tentacle/Commands/DeregisterMachineCommand.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Octopus.Diagnostics; using Octopus.Client; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Startup; using Octopus.Tentacle.Commands.OptionSets; @@ -35,7 +36,6 @@ public DeregisterMachineCommand(Lazy configuration, ILog protected override void Start() { - base.Start(); StartAsync().GetAwaiter().GetResult(); } @@ -55,10 +55,10 @@ public async Task Deregister(IOctopusAsyncRepository repository) var matchingMachines = await repository.Machines.FindByThumbprint(configuration.Value.TentacleCertificate.Thumbprint); if (matchingMachines.Count == 0) - throw new ArgumentException("No machine was found on the server matching this Tentacle's thumbprint."); + throw new ControlledFailureException("No machine was found on the server matching this Tentacle's thumbprint."); if (matchingMachines.Count > 1 && !allowMultiple) - throw new ArgumentException(MultipleMatchErrorMsg); + throw new ControlledFailureException(MultipleMatchErrorMsg); // 2. contact the server and de-register, this is independant to any tentacle configuration foreach (var machineResource in matchingMachines) diff --git a/source/Octopus.Tentacle/Commands/ExtractCommand.cs b/source/Octopus.Tentacle/Commands/ExtractCommand.cs index 69415351d..a48169f94 100644 --- a/source/Octopus.Tentacle/Commands/ExtractCommand.cs +++ b/source/Octopus.Tentacle/Commands/ExtractCommand.cs @@ -6,6 +6,7 @@ using Octopus.Shared.Util; using System.Threading; using Octopus.Diagnostics; +using Octopus.Shared; namespace Octopus.Tentacle.Commands { @@ -24,7 +25,7 @@ public ExtractCommand(Lazy packageInstaller, Lazy tentacleConfigurati protected override void Start() { - base.Start(); - if (!fromRegistry && string.IsNullOrWhiteSpace(importFile)) - throw new ArgumentException("Please specify the certificate to import."); + throw new ControlledFailureException("Please specify the certificate to import."); if (fromRegistry && !string.IsNullOrWhiteSpace(importFile)) - throw new ArgumentException("Please specify only one of either from-registry or from-file."); + throw new ControlledFailureException("Please specify only one of either from-registry or from-file."); X509Certificate2 x509Certificate = null; if (fromRegistry) @@ -49,7 +48,7 @@ protected override void Start() string encoded = GetEncodedCertificate(); if (string.IsNullOrWhiteSpace(encoded)) { - throw new ArgumentException("No Octopus 1.x Tentacle certificate was found."); + throw new ControlledFailureException("No Octopus 1.x Tentacle certificate was found."); } x509Certificate = CertificateEncoder.FromBase64String(encoded); } diff --git a/source/Octopus.Tentacle/Commands/NewCertificateCommand.cs b/source/Octopus.Tentacle/Commands/NewCertificateCommand.cs index bee4568aa..16b6e7f1e 100644 --- a/source/Octopus.Tentacle/Commands/NewCertificateCommand.cs +++ b/source/Octopus.Tentacle/Commands/NewCertificateCommand.cs @@ -2,6 +2,7 @@ using System.IO; using System.Text; using Octopus.Diagnostics; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Security; using Octopus.Shared.Security.Certificates; @@ -36,7 +37,7 @@ protected override void Start() { if (preserve && !string.IsNullOrWhiteSpace(exportFile)) - throw new ArgumentException("Invalid command: --if-blank and --export-file cannot be specified together"); + throw new ControlledFailureException("Invalid command: --if-blank and --export-file cannot be specified together"); if (!string.IsNullOrWhiteSpace(exportFile)) { @@ -48,8 +49,6 @@ protected override void Start() } else { - base.Start(); // Initialises Tentacle Instance. This is only required when pushing to config. - if (preserve && configuration.Value.TentacleCertificate != null) { log.Info("A certificate already exists, no changes will be applied."); diff --git a/source/Octopus.Tentacle/Commands/PollCommand.cs b/source/Octopus.Tentacle/Commands/PollCommand.cs index 30e279dbd..dc8a553d6 100644 --- a/source/Octopus.Tentacle/Commands/PollCommand.cs +++ b/source/Octopus.Tentacle/Commands/PollCommand.cs @@ -6,6 +6,7 @@ using Octopus.Client.Model; using Octopus.Client.Model.Endpoints; using Octopus.Diagnostics; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Startup; using Octopus.Tentacle.Commands.OptionSets; @@ -40,7 +41,6 @@ public PollCommand(Lazy configuration, ILog log, IApplic protected override void Start() { - base.Start(); StartAsync().GetAwaiter().GetResult(); } @@ -141,7 +141,7 @@ Uri GetAddress() case "wss": break; default: - throw new ArgumentException("The websocket address must start with wss://"); + throw new ControlledFailureException("The websocket address must start with wss://"); } return address; diff --git a/source/Octopus.Tentacle/Commands/RegisterMachineCommand.cs b/source/Octopus.Tentacle/Commands/RegisterMachineCommand.cs index 27f1c449e..f7f5c5ae1 100644 --- a/source/Octopus.Tentacle/Commands/RegisterMachineCommand.cs +++ b/source/Octopus.Tentacle/Commands/RegisterMachineCommand.cs @@ -67,21 +67,20 @@ public RegisterMachineCommand(Lazy lazyRegisterMachin protected override void Start() { - base.Start(); StartAsync().GetAwaiter().GetResult(); } async Task StartAsync() { if (environmentNames.Count == 0 || string.IsNullOrWhiteSpace(environmentNames.First())) - throw new ArgumentException("Please specify an environment name, e.g., --environment=Development"); + throw new ControlledFailureException("Please specify an environment name, e.g., --environment=Development"); CommunicationStyle communicationStyle; if (!Enum.TryParse(comms, true, out communicationStyle)) - throw new ArgumentException("Please specify a valid communications style, e.g. --comms-style=TentaclePassive"); + throw new ControlledFailureException("Please specify a valid communications style, e.g. --comms-style=TentaclePassive"); if (configuration.Value.TentacleCertificate == null) - throw new ArgumentException("No certificate has been generated for this Tentacle. Please run the new-certificate command first."); + throw new ControlledFailureException("No certificate has been generated for this Tentacle. Please run the new-certificate command first."); Uri serverAddress = null; @@ -170,7 +169,7 @@ Uri GetActiveTentacleAddress() case "wss": break; default: - throw new ArgumentException("The websocket address must start with wss://"); + throw new ControlledFailureException("The websocket address must start with wss://"); } return address; diff --git a/source/Octopus.Tentacle/Commands/RunAgentCommand.cs b/source/Octopus.Tentacle/Commands/RunAgentCommand.cs index 1db9ef917..4d8ee0114 100644 --- a/source/Octopus.Tentacle/Commands/RunAgentCommand.cs +++ b/source/Octopus.Tentacle/Commands/RunAgentCommand.cs @@ -51,8 +51,6 @@ public RunAgentCommand( protected override void Start() { - base.Start(); - if (wait >= 20) { log.Info("Sleeping for " + wait + "ms..."); diff --git a/source/Octopus.Tentacle/Commands/ServerCommsCommand.cs b/source/Octopus.Tentacle/Commands/ServerCommsCommand.cs index 51b51aeb4..753bd2c24 100644 --- a/source/Octopus.Tentacle/Commands/ServerCommsCommand.cs +++ b/source/Octopus.Tentacle/Commands/ServerCommsCommand.cs @@ -3,6 +3,7 @@ using Halibut; using Octopus.Client.Model; using Octopus.Diagnostics; +using Octopus.Shared; using Octopus.Shared.Configuration; using Octopus.Shared.Startup; using Octopus.Shared.Util; @@ -35,26 +36,24 @@ public ServerCommsCommand(Lazy tentacleConfiguration, IL protected override void Start() { - base.Start(); - if (!tentacleConfiguration.Value.TrustedOctopusThumbprints.Any()) - throw new ArgumentException("Before server communications can be modified, trust must be established with the configure command"); + throw new ControlledFailureException("Before server communications can be modified, trust must be established with the configure command"); if (string.IsNullOrWhiteSpace(serverThumbprint)) { if (tentacleConfiguration.Value.TrustedOctopusThumbprints.Count() != 1) - throw new ArgumentException("More than one server is trusted; please provide the thumbprint of the server to configure, e.g. --thumbprint=..."); + throw new ControlledFailureException("More than one server is trusted; please provide the thumbprint of the server to configure, e.g. --thumbprint=..."); serverThumbprint = tentacleConfiguration.Value.TrustedOctopusThumbprints.Single(); } CommunicationStyle communicationStyle; if (!Enum.TryParse(style, true, out communicationStyle)) - throw new ArgumentException("Please specify a valid communications style, e.g. --style=TentaclePassive"); + throw new ControlledFailureException("Please specify a valid communications style, e.g. --style=TentaclePassive"); var servers = tentacleConfiguration.Value.TrustedOctopusServers.Where(s => s.Thumbprint == serverThumbprint).ToArray(); if (servers.None()) - throw new ArgumentException("No trusted server was found with the supplied thumbprint"); + throw new ControlledFailureException("No trusted server was found with the supplied thumbprint"); if (communicationStyle == CommunicationStyle.TentacleActive) @@ -95,10 +94,10 @@ Uri GetActiveAddress() var hasHost = !string.IsNullOrWhiteSpace(serverHost); var hasWebSocket = !string.IsNullOrWhiteSpace(webSocket); if (!hasHost && !hasWebSocket) - throw new ArgumentException("Please provide either the server hostname or websocket address, e.g. --host=OCTOPUS"); + throw new ControlledFailureException("Please provide either the server hostname or websocket address, e.g. --host=OCTOPUS"); if (hasHost && hasWebSocket) - throw new ArgumentException("The hostname and websocket options cannot be used together"); + throw new ControlledFailureException("The hostname and websocket options cannot be used together"); if (hasHost) return new Uri($"https://{serverHost}:{serverPort}"); @@ -113,7 +112,7 @@ Uri GetActiveAddress() case "wss": break; default: - throw new ArgumentException("The websocket address must start with wss://"); + throw new ControlledFailureException("The websocket address must start with wss://"); } return address; diff --git a/source/Octopus.Tentacle/Commands/ShowThumbprintCommand.cs b/source/Octopus.Tentacle/Commands/ShowThumbprintCommand.cs index 80e41d1f5..735ce3292 100644 --- a/source/Octopus.Tentacle/Commands/ShowThumbprintCommand.cs +++ b/source/Octopus.Tentacle/Commands/ShowThumbprintCommand.cs @@ -26,7 +26,6 @@ public ShowThumbprintCommand(Lazy tentacleConfiguration, protected override void Start() { - base.Start(); var thumbprint = tentacleConfiguration.Value.TentacleCertificate.Thumbprint; log.Info((thumbprintOnly ? "" : "The thumbprint of this Tentacle is: ") + thumbprint); if (!string.IsNullOrWhiteSpace(exportFile)) diff --git a/source/Octopus.Tentacle/Octopus.Tentacle.csproj b/source/Octopus.Tentacle/Octopus.Tentacle.csproj index ddd45d660..c4f700a08 100644 --- a/source/Octopus.Tentacle/Octopus.Tentacle.csproj +++ b/source/Octopus.Tentacle/Octopus.Tentacle.csproj @@ -16,7 +16,7 @@ - +