Skip to content

Commit 5dfe172

Browse files
committed
Check that server major/minor is higher than client major/minor
1 parent b0d09fa commit 5dfe172

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/ServiceControl.RavenDB/ServiceControl.RavenDB.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageReference Include="ByteSize" />
1010
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
1111
<PackageReference Include="NServiceBus" />
12+
<PackageReference Include="NuGet.Versioning" />
1213
<PackageReference Include="RavenDB.Embedded" />
1314
</ItemGroup>
1415

src/ServiceControl.RavenDB/StartupChecks.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System.Reflection;
44
using System.Threading;
5+
using NuGet.Versioning;
56
using Raven.Client.Documents;
67
using Raven.Client.ServerWide.Operations;
78

@@ -11,14 +12,16 @@ public static async Task EnsureServerVersion(IDocumentStore store, CancellationT
1112
{
1213
var build = await store.Maintenance.Server.SendAsync(new GetBuildNumberOperation(), cancellationToken);
1314

14-
var clientVersion = typeof(Raven.Client.Constants).Assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().First().InformationalVersion;
15-
var parts = clientVersion.Split('.');
16-
var clientProductVersion = $"{parts[0]}.{parts[1]}";
15+
var clientVersion = SemanticVersion.Parse(typeof(Raven.Client.Constants).Assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().First().InformationalVersion);
16+
var serverVersion = NuGetVersion.Parse(build.ProductVersion);
1717

18-
if (clientProductVersion != build.ProductVersion)
18+
var serverHasLowerMajorMinor = serverVersion.Major < clientVersion.Major
19+
|| (serverVersion.Major == clientVersion.Major && serverVersion.Minor < clientVersion.Minor);
20+
21+
if (serverHasLowerMajorMinor)
1922
{
20-
throw new Exception($"ServiceControl expects RavenDB Server version {clientProductVersion} but the server is using {build.ProductVersion}.");
23+
throw new Exception($"ServiceControl expects at minimum RavenDB Server version {clientVersion.Major}.{clientVersion.Minor} but the server is using {build.ProductVersion}.");
2124
}
2225
}
2326
}
24-
}
27+
}

0 commit comments

Comments
 (0)