Skip to content

.NET 8 and AOT compatibility #1395

Closed
Closed

Description

@guillaume-chervet

Describe the bug

Than you for your work ont this library about kubernetes :)

We would like to activate .NET 8 AOT on SlimFaas which is also an open source project.
Compilation work, but execution crash on that line : https://github.com/AxaFrance/SlimFaas/blob/5c5a1f39ae3b0e6bee8a8cdf27ec85f95607b404/src/SlimFaas/Kubernetes/KubernetesService.cs#L66

--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
at k8s.AbstractKubernetes.<IAppsV1Operations_ListNamespacedDeploymentWithHttpMessagesAsync>d__606`1.MoveNext() + 0x664

...

System.InvalidOperationException: JsonSerializerOptions instance must specify a TypeInfoResolver setting before being marked as read-only.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerOptionsNoTypeInfoResolverSpecified() + 0x27
at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() + 0x20
at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions, Type) + 0x2d
at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions) + 0x2b
at System.Text.Json.JsonSerializer.Deserialize[TValue](Stream, JsonSerializerOptions) + 0x1f
at k8s.Kubernetes.<CreateResultAsync>d__46`1.MoveNext() + 0x249

The SlimFaas PullRequest : SlimPlanet/SlimFaas#23

Kubernetes C# SDK Client Version

 <PackageReference Include="KubernetesClient" Version="12.0.16" />

Dotnet Runtime Version
8.0.100-preview.7.23376.3

To Reproduce
Build an AOT program which use this function : https://github.com/AxaFrance/SlimFaas/blob/5c5a1f39ae3b0e6bee8a8cdf27ec85f95607b404/src/SlimFaas/Kubernetes/KubernetesService.cs#L66

Expected behavior
Does not crash once compile with AOT

### Tasks
- [ ] https://github.com/kubernetes-client/csharp/pull/1417

Activity

  1. IvanJosipovic commented on Sep 7, 2023

    @IvanJosipovic
    Contributor

    This looks to be related to #1311

  2. tg123 commented on Sep 7, 2023

    @tg123
    Member

    AOT will be supported for sure

  3. changed the title [-].NET 8 and OAT compatibility[/-] [+].NET 8 and AOT compatibility[/+] on Sep 11, 2023
  4. guillaume-chervet commented on Sep 12, 2023

    @guillaume-chervet
    Author

    Can't wait for it 😜 it would be awesome!

  5. tg123 commented on Sep 14, 2023

    @tg123
    Member

    PR is also welcomed,

  6. m3nax commented on Nov 24, 2023

    @m3nax
    Contributor

    related #1463

  7. tg123 commented on Dec 14, 2023

    @tg123
    Member

    hi @guillaume-chervet here is a draft version of aot
    too many warnings and many things need to be fixed
    but first working code

    https://github.com/tg123/csharp/tree/aotfinal/examples/aot

    dotnet publish -r win-x64 -c Debug
    

    ~20M binary

    your input is welcomed, i am still working on cleaning things up

  8. guillaume-chervet commented on Dec 15, 2023

    @guillaume-chervet
    Author

    Hi @tg123 thank you very much! Is it possible to publish alpha version? I need at least a working trimming mode. AOT will be the next step.

  9. tg123 commented on Dec 18, 2023

    @tg123
    Member

    seems too many lib to cleanu, i am thinking add a Kubenetesclient.AOT for aot only

    why do you want trim only? btw

  10. guillaume-chervet commented on Dec 18, 2023

    @guillaume-chervet
    Author

    AOT will be very fine, but Trimming for à first step will be Nice. This discution is interresting dotnet/dotNext#200 (comment)

  11. guillaume-chervet commented on Jan 3, 2024

    @guillaume-chervet
    Author

    Hi @tg123 are your still working on this?

    I really need to activate trimming and better will be AOT for Slimfaas :
    https://github.com/AxaFrance/SlimFaas

    I may be will have more time if you need some help.

  12. tg123 commented on Jan 3, 2024

    @tg123
    Member

    yup please allow more time on this

  13. guillaume-chervet commented on Jan 30, 2024

    @guillaume-chervet
    Author

    hi @tg123 ,

    Thank you s much for your work.
    Is it possible to publish a beta of KubernetesClient.Aot ?

    in order to be able to test it :)

  14. guillaume-chervet commented on Feb 2, 2024

    @guillaume-chervet
    Author

    I have tested it @tg123 ,

    List deployments and statefulset works well. For the moment I Have activated Trimming mode (I will test AOT after having a working trimmin mode).

    When try to scale down for example It crash.

    2024-02-02 09:22:36 fail: SlimFaas.ScaleReplicasWorker[0]
    2024-02-02 09:22:36       Global Error in ScaleReplicasWorker
    2024-02-02 09:22:36       System.ArgumentNullException: Value cannot be null. (Parameter 'jsonTypeInfo')
    2024-02-02 09:22:36          at System.Text.Json.ThrowHelper.ThrowArgumentNullException(String)
    2024-02-02 09:22:36          at k8s.Kubernetes.SendRequest[T](String, HttpMethod, IReadOnlyDictionary`2, T, CancellationToken)
    2024-02-02 09:22:36          at k8s.AbstractKubernetes.IAppsV1Operations_PatchNamespacedDeploymentScaleWithHttpMessagesAsync[T](V1Patch, String, String, String, String, String, Nullable`1, Nullable`1, IReadOnlyDictionary`2, CancellationToken)
    2024-02-02 09:22:36          at k8s.AbstractKubernetes.k8s.IAppsV1Operations.PatchNamespacedDeploymentScaleWithHttpMessagesAsync(V1Patch, String, String, String, String, String, Nullable`1, Nullable`1, IReadOnlyDictionary`2, CancellationToken)
    2024-02-02 09:22:36          at k8s.AppsV1OperationsExtensions.PatchNamespacedDeploymentScaleAsync(IAppsV1Operations, V1Patch, String, String, String , String , String , Nullable`1 , Nullable`1 , CancellationToken )
    2024-02-02 09:22:36          at SlimFaas.Kubernetes.KubernetesService.ScaleAsync(ReplicaRequest request)
    2024-02-02 09:22:36          at SlimFaas.ReplicasService.CheckScaleAsync(String kubeNamespace)
    2024-02-02 09:22:36          at SlimFaas.ScaleReplicasWorker.ExecuteAsync(CancellationToken stoppingToken)
    

    The code :
    image

    Do you hav e an idea @tg123 ?

  15. tg123 commented on Feb 2, 2024

    @tg123
    Member

    patch is not supported in aot yet

  16. guillaume-chervet commented on Feb 2, 2024

    @guillaume-chervet
    Author

    Hi @tg123 ,

    Do you think it will be very soon ?
    My Image shrink a lot just with Timming. I Can't wait to see used ram in production in trimming mode or AOT :)
    image

    https://github.com/AxaFrance/SlimFaas

  17. tg123 commented on Feb 2, 2024

    @tg123
    Member

    i am working on watch
    but let me see if i can make patch aot first

  18. guillaume-chervet commented on Feb 2, 2024

    @guillaume-chervet
    Author

    @tg123 Thank you,
    patch aot first would be awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions