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
22 changes: 17 additions & 5 deletions src/ServiceControl.Config/Commands/UpgradeAuditInstanceCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ServiceControl.Config.Commands
{
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading.Tasks;
using Caliburn.Micro;
Expand Down Expand Up @@ -50,14 +51,25 @@ public override async Task ExecuteAsync(InstanceDetailsViewModel model)
var instance = InstanceFinder.FindInstanceByName<ServiceControlAuditInstance>(model.Name);
instance.Service.Refresh();

if (instance.PersistenceManifest.Name == "RavenDB35")
var compatibleStorageEngine = instance.PersistenceManifest.Name == StorageEngineNames.RavenDB5;

if (!compatibleStorageEngine)
{
var docsUrl = "https://docs.particular.net/servicecontrol/upgrades/zero-downtime";
var upgradeGuide4to5url = "https://docs.particular.net/servicecontrol/upgrades/4to5/";

await windowManager.ShowMessage("UPGRADE NOTE",
$@"Please note that the storage format has changed and that upgrading existing instances using RavenDB 3.5 will only be supported for a limited period of time.
var openUpgradeGuide = await windowManager.ShowYesNoDialog("STORAGE ENGINE INCOMPATIBLE",
$"Please note that the storage format has changed and the {instance.PersistenceManifest.DisplayName} storage engine is no longer available. Upgrading requires a side-by-side deployment of both versions. Migration guidance is available in the version 4 to 5 upgrade guidance at {upgradeGuide4to5url}",
"Open online ServiceControl 4 to 5 upgrade guide in system default browser?",
"Yes",
"No"
);

See our zero downtime upgrade guidance, {docsUrl}, for instructions how migrate to the new storage format by adding a new audit instance.", hideCancel: true);
if (openUpgradeGuide)
{
Process.Start(new ProcessStartInfo(upgradeGuide4to5url) { UseShellExecute = true });
}

return;
}

var upgradeInfo = UpgradeControl.GetUpgradeInfoForTargetVersion(serviceControlInstaller.ZipInfo.Version, instance.Version);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ServiceControl.Config.Commands
{
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading.Tasks;
using Caliburn.Micro;
Expand Down Expand Up @@ -60,6 +61,27 @@ public override async Task ExecuteAsync(InstanceDetailsViewModel model)

instance.Service.Refresh();

var compatibleStorageEngine = instance.PersistenceManifest.Name == StorageEngineNames.RavenDB5;

if (!compatibleStorageEngine)
{
var upgradeGuide4to5url = "https://docs.particular.net/servicecontrol/upgrades/4to5/";

var openUpgradeGuide = await windowManager.ShowYesNoDialog("STORAGE ENGINE INCOMPATIBLE",
$"Please note that the storage format has changed and the {instance.PersistenceManifest.DisplayName} storage engine is no longer available. Upgrading requires a side-by-side deployment of both versions. Migration guidance is available in the version 4 to 5 upgrade guidance at {upgradeGuide4to5url}",
"Open online ServiceControl 4 to 5 upgrade guide in system default browser?",
"Yes",
"No"
);

if (openUpgradeGuide)
{
Process.Start(new ProcessStartInfo(upgradeGuide4to5url) { UseShellExecute = true });
}

return;
}

var upgradeInfo = UpgradeControl.GetUpgradeInfoForTargetVersion(serviceControlInstaller.ZipInfo.Version, instance.Version);
var upgradeOptions = new ServiceControlUpgradeOptions { UpgradeInfo = upgradeInfo };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ protected override void ProcessRecord()

foreach (var name in Name)
{
var instance = InstanceFinder.FindServiceControlInstance(name);
if (instance == null)
if (InstanceFinder.FindServiceControlInstance(name) is not ServiceControlAuditInstance instance)
{
WriteWarning($"No action taken. An instance called {name} was not found");
WriteWarning($"No action taken. An audit instance called {name} was not found");
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static ServiceControlAuditNewInstance CreateWithDefaultPersistence()

public static ServiceControlAuditNewInstance CreateWithDefaultPersistence(string deploymentCachePath)
{
const string persisterToUseForBrandNewInstances = "RavenDB5";
const string persisterToUseForBrandNewInstances = StorageEngineNames.RavenDB5;
return CreateWithPersistence(deploymentCachePath, persisterToUseForBrandNewInstances);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static ServiceControlNewInstance CreateWithDefaultPersistence()

public static ServiceControlNewInstance CreateWithDefaultPersistence(string deploymentCachePath)
{
const string persisterUsedForBrandNewInstances = "RavenDB5";
const string persisterUsedForBrandNewInstances = StorageEngineNames.RavenDB5;
return CreateWithPersistence(deploymentCachePath, persisterUsedForBrandNewInstances);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ServiceControlInstaller.Engine.Instances
{
public static class StorageEngineNames
{
public const string RavenDB5 = "RavenDB5";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ public async Task<bool> Add(ServiceControlAuditNewInstance details, Func<PathInf
return true;
}

public bool Upgrade(ServiceControlBaseService instance)
public bool Upgrade(ServiceControlAuditInstance instance)
{
var compatibleStorageEngine = instance.PersistenceManifest.Name == StorageEngineNames.RavenDB5;

if (!compatibleStorageEngine)
{
var upgradeGuide4to5url = "https://docs.particular.net/servicecontrol/upgrades/4to5/";
logger.Error($"Upgrade aborted. Please note that the storage format has changed and the {instance.PersistenceManifest.DisplayName} storage engine is no longer available. Upgrading requires a side-by-side deployment of both versions. Migration guidance is available in the version 4 to 5 upgrade guidance at {upgradeGuide4to5url}");
return false;
}

ZipInfo.ValidateZip();

var checkLicenseResult = CheckLicenseIsValid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public async Task<bool> Add(ServiceControlNewInstance details, Func<PathInfo, Ta

public bool Upgrade(ServiceControlInstance instance, ServiceControlUpgradeOptions options)
{
var compatibleStorageEngine = instance.PersistenceManifest.Name == StorageEngineNames.RavenDB5;

if (!compatibleStorageEngine)
{
var upgradeGuide4to5url = "https://docs.particular.net/servicecontrol/upgrades/4to5/";
logger.Error($"Upgrade aborted. Please note that the storage format has changed and the {instance.PersistenceManifest.DisplayName} storage engine is no longer available. Upgrading requires a side-by-side deployment of both versions. Migration guidance is available in the version 4 to 5 upgrade guidance at {upgradeGuide4to5url}");
return false;
}

if (instance.Version < options.UpgradeInfo.CurrentMinimumVersion)
{
logger.Error($"Upgrade aborted. An interim upgrade to version {options.UpgradeInfo.RecommendedUpgradeVersion} is required before upgrading to version {ZipInfo.Version}. Download available at https://github.com/Particular/ServiceControl/releases/tag/{options.UpgradeInfo.RecommendedUpgradeVersion}");
Expand Down