From af73f197b4d426f5fffae68840a36e1a5a88857b Mon Sep 17 00:00:00 2001 From: Christophe Chevalier Date: Tue, 23 Jan 2024 12:10:03 +0100 Subject: [PATCH] Aspire: update to nightly 8.0.0-preview.3.24072.10 --- .../Aspire.FoundationDB.Hosting.csproj | 2 +- Aspire.FoundationDB.Hosting/FdbAspireHostingExtensions.cs | 2 +- Aspire.FoundationDB.Hosting/FdbClusterResource.cs | 2 ++ Aspire.FoundationDB.Hosting/FdbConnectionResource.cs | 1 + Aspire.FoundationDB.Hosting/FdbContainerResource.cs | 8 ++++++-- Aspire.FoundationDB.Hosting/FdbVersionPolicy.cs | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Aspire.FoundationDB.Hosting/Aspire.FoundationDB.Hosting.csproj b/Aspire.FoundationDB.Hosting/Aspire.FoundationDB.Hosting.csproj index ec44ca856..88a8beb01 100644 --- a/Aspire.FoundationDB.Hosting/Aspire.FoundationDB.Hosting.csproj +++ b/Aspire.FoundationDB.Hosting/Aspire.FoundationDB.Hosting.csproj @@ -21,7 +21,7 @@ - + diff --git a/Aspire.FoundationDB.Hosting/FdbAspireHostingExtensions.cs b/Aspire.FoundationDB.Hosting/FdbAspireHostingExtensions.cs index a5bd2839c..3bbea5ae3 100644 --- a/Aspire.FoundationDB.Hosting/FdbAspireHostingExtensions.cs +++ b/Aspire.FoundationDB.Hosting/FdbAspireHostingExtensions.cs @@ -222,7 +222,7 @@ private static IResourceBuilder ConfigureContainer(IResour { return container .WithAnnotation(new ManifestPublishingCallbackAnnotation((ctx) => WriteFdbContainerToManifest(ctx, container.Resource))) - .WithAnnotation(new ServiceBindingAnnotation(ProtocolType.Tcp, port: container.Resource.Port, containerPort: 4550)) // default container port is set to 4550 + .WithAnnotation(new EndpointAnnotation(ProtocolType.Tcp, port: container.Resource.Port, containerPort: 4550)) // default container port is set to 4550 .WithAnnotation(new ContainerImageAnnotation { Image = "foundationdb/foundationdb", Tag = container.Resource.DockerTag }) .WithVolumeMount("fdb_data", "/var/fdb/data", VolumeMountType.Named, isReadOnly: false) //HACKHACK: TODO: make this configurable! .WithEnvironment((context) => diff --git a/Aspire.FoundationDB.Hosting/FdbClusterResource.cs b/Aspire.FoundationDB.Hosting/FdbClusterResource.cs index 385a6caef..7b0b2acf3 100644 --- a/Aspire.FoundationDB.Hosting/FdbClusterResource.cs +++ b/Aspire.FoundationDB.Hosting/FdbClusterResource.cs @@ -14,6 +14,7 @@ namespace Aspire.Hosting.ApplicationModel using System.Globalization; using System.Linq; using System.Net; + using Doxense.Diagnostics.Contracts; using FoundationDB.Client; public class FdbClusterResource : Resource, IFdbResource @@ -74,6 +75,7 @@ public int GetNextPort() internal FdbContainerResource CreateContainer(string name, bool coordinator) { + Contract.Debug.Requires(name != null); var fdbContainer = new FdbContainerResource(name, this) { diff --git a/Aspire.FoundationDB.Hosting/FdbConnectionResource.cs b/Aspire.FoundationDB.Hosting/FdbConnectionResource.cs index 7e1fa71ac..d1785862b 100644 --- a/Aspire.FoundationDB.Hosting/FdbConnectionResource.cs +++ b/Aspire.FoundationDB.Hosting/FdbConnectionResource.cs @@ -8,6 +8,7 @@ namespace Aspire.Hosting.ApplicationModel { + using System; using System.Data.Common; using FoundationDB.Client; diff --git a/Aspire.FoundationDB.Hosting/FdbContainerResource.cs b/Aspire.FoundationDB.Hosting/FdbContainerResource.cs index 0200e856c..f162027f5 100644 --- a/Aspire.FoundationDB.Hosting/FdbContainerResource.cs +++ b/Aspire.FoundationDB.Hosting/FdbContainerResource.cs @@ -10,11 +10,13 @@ namespace Aspire.Hosting.ApplicationModel { using System.Linq; using System.Net; + using Doxense.Diagnostics.Contracts; public class FdbContainerResource : ContainerResource, IFdbResource, IResourceWithParent { public FdbContainerResource(string name, FdbClusterResource parent) : base(name) { + Contract.NotNull(parent); this.Parent = parent; } @@ -30,15 +32,17 @@ public FdbContainerResource(string name, FdbClusterResource parent) : base(name) internal EndPoint GetEndpoint() { - if (!this.TryGetServiceBindings(out var bindings)) + if (!this.TryGetAllocatedEndPoints(out var bindings)) { throw new DistributedApplicationException("Expected allocated endpoints!"); } var allocatedEndpoint = bindings.Single(); + //note: we expect the address to be "localhost". + Contract.Debug.Assert(allocatedEndpoint.Address == "localhost"); var addr = IPAddress.Loopback; - var port = allocatedEndpoint.Port ?? this.Port; + var port = allocatedEndpoint.Port; return new IPEndPoint(addr, port); } diff --git a/Aspire.FoundationDB.Hosting/FdbVersionPolicy.cs b/Aspire.FoundationDB.Hosting/FdbVersionPolicy.cs index 985f835da..63633c8f4 100644 --- a/Aspire.FoundationDB.Hosting/FdbVersionPolicy.cs +++ b/Aspire.FoundationDB.Hosting/FdbVersionPolicy.cs @@ -10,6 +10,7 @@ namespace Aspire.Hosting.ApplicationModel { using System; + /// Specify the versionning rules for the FoundationDB docker image public enum FdbVersionPolicy { /// Use the exact version specified