-
Notifications
You must be signed in to change notification settings - Fork 910
Enable AOT compatibility for Yarp.Kubernetes.Controller #3010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/enable-aot-compatibility
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0bebe98
Initial plan
Copilot 6245b34
Initial plan for AOT compatibility
Copilot ad10145
Enable AOT compatibility for Yarp.Kubernetes.Controller
Copilot dd0c957
Add AOT compatibility test app for Yarp.Kubernetes.Controller
Copilot b5bf7f6
Update AOT test app: net10.0 TFM, all AOT-compatible project refs, an…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Kubernetes.Controller/Protocol/KubernetesJsonSerializerContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Text.Json.Serialization; | ||
| using Yarp.Kubernetes.Protocol; | ||
| using Yarp.ReverseProxy.Configuration; | ||
|
|
||
| namespace Yarp.Kubernetes.Controller.Protocol; | ||
|
|
||
| [JsonSerializable(typeof(Message))] | ||
| [JsonSerializable(typeof(List<RouteConfig>))] | ||
| [JsonSerializable(typeof(List<ClusterConfig>))] | ||
| internal sealed partial class KubernetesJsonSerializerContext : JsonSerializerContext | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| // This app is used to test AOT compatibility of all AOT-compatible YARP assemblies. | ||
| // It exercises the main public API surface to ensure no AOT/trimming warnings | ||
| // are emitted at build or publish time. | ||
|
|
||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Yarp.Kubernetes.Protocol; | ||
|
|
||
| // Combined controller scenario (ingress controller + YARP reverse proxy) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.WebHost.UseKubernetesReverseProxyCertificateSelector(); | ||
| builder.Services.AddKubernetesReverseProxy(builder.Configuration); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // Monitor-only scenario (ingress monitor + dispatch controller) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddKubernetesIngressMonitor(builder.Configuration); | ||
| builder.Services.AddControllers().AddKubernetesDispatchController(); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // Receiver scenario (side-car that receives config from ingress monitor) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.Configure<ReceiverOptions>(builder.Configuration.Bind); | ||
| builder.Services.AddHostedService<Receiver>(); | ||
| builder.Services.AddReverseProxy().LoadFromMessages(); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // ReverseProxy standalone scenario | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddReverseProxy() | ||
| .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // TelemetryConsumption scenario | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddTelemetryListeners(); | ||
| _ = builder.Build(); | ||
| } |
22 changes: 22 additions & 0 deletions
22
...ssets/Kubernetes.AotCompatibility.TestApp/Yarp.Kubernetes.AotCompatibility.TestApp.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <OutputType>Exe</OutputType> | ||
| <PublishAot>true</PublishAot> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Kubernetes.Controller\Yarp.Kubernetes.Controller.csproj" /> | ||
| <ProjectReference Include="..\..\src\ReverseProxy\Yarp.ReverseProxy.csproj" /> | ||
| <ProjectReference Include="..\..\src\TelemetryConsumption\Yarp.Telemetry.Consumption.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <TrimmerRootAssembly Include="Yarp.Kubernetes.Controller" /> | ||
| <TrimmerRootAssembly Include="Yarp.ReverseProxy" /> | ||
| <TrimmerRootAssembly Include="Yarp.Telemetry.Consumption" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - this should reference all the projects that are AOT compatible in teh repo.
Also, it needs
TrimmerRootAssemblyfor each one. see https://github.com/dotnet/extensions/blob/b3f2f408fe70f0d8e1f8fb2385bcfc8e9e81158d/test/Libraries/Microsoft.Extensions.AotCompatibility.TestApp/Microsoft.Extensions.AotCompatibility.TestApp.csproj for an exampleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b5bf7f6. The csproj now references all three AOT-compatible YARP assemblies with
TrimmerRootAssemblyfor each, and Program.cs adds scenarios forAddReverseProxy().LoadFromConfig(...)andAddTelemetryListeners().