Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/Octopus.Manager.Tentacle/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
<HintPath>..\packages\Octopus.Diagnostics.1.0.11\lib\netstandard1.0\Octopus.Diagnostics.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octopus.Manager.Core, Version=3.13.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Manager.Core.3.13.9-tentsplit0048\lib\Octopus.Manager.Core.dll</HintPath>
<Reference Include="Octopus.Manager.Core, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Manager.Core.3.14.1-enh-showdbupgrad0062\lib\Octopus.Manager.Core.dll</HintPath>
</Reference>
<Reference Include="Octopus.Shared, Version=3.14.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Shared.3.14.0-beta0005\lib\Octopus.Shared.dll</HintPath>
<Reference Include="Octopus.Shared, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Shared.3.14.1-enh-showdbupgrad0062\lib\Octopus.Shared.dll</HintPath>
</Reference>
<Reference Include="Octopus.Time, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Time.1.0.8\lib\netstandard1.0\Octopus.Time.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,13 @@ string[] SelectedTenantsArray

public IEnumerable<CommandLineInvocation> 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();
yield return Cli("new-certificate").Flag("if-blank").Build();
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions source/Octopus.Manager.Tentacle/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<package id="Octopus.Client" version="4.15.2" targetFramework="net45" />
<package id="Octopus.Configuration" version="1.0.10" targetFramework="net45" />
<package id="Octopus.Diagnostics" version="1.0.11" targetFramework="net45" />
<package id="Octopus.Manager.Core" version="3.13.9-tentsplit0048" targetFramework="net45" />
<package id="Octopus.Shared" version="3.14.0-beta0005" targetFramework="net45" />
<package id="Octopus.Manager.Core" version="3.14.1-enh-showdbupgrad0062" targetFramework="net45" />
<package id="Octopus.Shared" version="3.14.1-enh-showdbupgrad0062" targetFramework="net45" />
<package id="Octopus.Time" version="1.0.8" targetFramework="net45" />
<package id="System.Net.Http" version="4.1.0" targetFramework="net45" />
<package id="System.Runtime" version="4.1.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +51,7 @@ public async Task ShouldNotContinueIfMultipleMatchesButAllowMultipleIsNotSupplie
asyncRepository.Machines.FindByThumbprint(Arg.Any<string>())
.ReturnsForAnyArgs(matchingMachines.AsTask());

var result = Assert.Throws<ArgumentException>( async () => await Command.Deregister(asyncRepository));
var result = Assert.Throws<ControlledFailureException>( async () => await Command.Deregister(asyncRepository));

Assert.That(result.Message.Equals(DeregisterMachineCommand.MultipleMatchErrorMsg));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,7 +79,7 @@ static void Assert(OctopusServerConfiguration server, string thumbprint, Communi
public void NoTrusts()
{
Action action = () => Execute(Thumb1, CommunicationStyle.TentaclePassive);
action.ShouldThrow<ArgumentException>()
action.ShouldThrow<ControlledFailureException>()
.WithMessage("Before server communications can be modified, trust must be established with the configure command");
}

Expand All @@ -98,7 +99,7 @@ public void AddActiveNoHost()
{
AddTrusts(Thumb1);
Action action = () => Execute(Thumb1, CommunicationStyle.TentacleActive, null, "1234");
action.ShouldThrow<ArgumentException>()
action.ShouldThrow<ControlledFailureException>()
.WithMessage("Please provide either the server hostname or websocket address, e.g. --host=OCTOPUS");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Octopus.Shared, Version=3.14.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Shared.3.14.1-enh-sha256-ui0002\lib\Octopus.Shared.dll</HintPath>
<HintPath>..\packages\Octopus.Shared.3.14.1-enh-showdbupgrad0062\lib\Octopus.Shared.dll</HintPath>
</Reference>
<Reference Include="Octopus.Time, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octopus.Time.1.0.8\lib\netstandard1.0\Octopus.Time.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion source/Octopus.Tentacle.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<package id="Octopus.Diagnostics" version="1.0.11" targetFramework="net452" />
<package id="Octopus.Server.Extensibility" version="2.0.2" targetFramework="net452" />
<package id="Octopus.Server.Extensibility.Authentication" version="3.0.0" targetFramework="net452" />
<package id="Octopus.Shared" version="3.14.1-enh-sha256-ui0002" targetFramework="net452" />
<package id="Octopus.Shared" version="3.14.1-enh-showdbupgrad0062" targetFramework="net452" />
<package id="Octopus.Time" version="1.0.8" targetFramework="net452" />
<package id="Octostache" version="2.1.5" targetFramework="net452" />
<package id="Polly" version="5.1.0" targetFramework="net452" />
Expand Down
2 changes: 0 additions & 2 deletions source/Octopus.Tentacle/Commands/ConfigureCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public ConfigureCommand(

protected override void Start()
{
base.Start();

if (resetTrust)
{
log.Info("Removing all trusted Octopus servers...");
Expand Down
6 changes: 3 additions & 3 deletions source/Octopus.Tentacle/Commands/DeregisterMachineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,7 +36,6 @@ public DeregisterMachineCommand(Lazy<ITentacleConfiguration> configuration, ILog

protected override void Start()
{
base.Start();
StartAsync().GetAwaiter().GetResult();
}

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion source/Octopus.Tentacle/Commands/ExtractCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Octopus.Shared.Util;
using System.Threading;
using Octopus.Diagnostics;
using Octopus.Shared;

namespace Octopus.Tentacle.Commands
{
Expand All @@ -24,7 +25,7 @@ public ExtractCommand(Lazy<IPackageInstaller> packageInstaller, Lazy<IOctopusFil
var fullPath = fileSystem.Value.GetFullPath(v);
fileSystem.Value.EnsureDirectoryExists(Path.GetDirectoryName(fullPath));
if (!fileSystem.Value.FileExists(fullPath))
throw new ArgumentException("Package not found: " + fullPath);
throw new ControlledFailureException("Package not found: " + fullPath);

log.Info("Package: " + fullPath);
packageFile = fullPath;
Expand Down
9 changes: 4 additions & 5 deletions source/Octopus.Tentacle/Commands/ImportCertificateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using Microsoft.Win32;
using Octopus.Diagnostics;
using Octopus.Shared;
using Octopus.Shared.Configuration;
using Octopus.Shared.Security;
using Octopus.Shared.Security.Certificates;
Expand Down Expand Up @@ -33,13 +34,11 @@ public ImportCertificateCommand(Lazy<ITentacleConfiguration> 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)
Expand All @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions source/Octopus.Tentacle/Commands/NewCertificateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand All @@ -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.");
Expand Down
4 changes: 2 additions & 2 deletions source/Octopus.Tentacle/Commands/PollCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -40,7 +41,6 @@ public PollCommand(Lazy<ITentacleConfiguration> configuration, ILog log, IApplic

protected override void Start()
{
base.Start();
StartAsync().GetAwaiter().GetResult();
}

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions source/Octopus.Tentacle/Commands/RegisterMachineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,20 @@ public RegisterMachineCommand(Lazy<IRegisterMachineOperation> 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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions source/Octopus.Tentacle/Commands/RunAgentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public RunAgentCommand(

protected override void Start()
{
base.Start();

if (wait >= 20)
{
log.Info("Sleeping for " + wait + "ms...");
Expand Down
Loading