Skip to content

AOT support and Kubernetes Provider #2145

@davidwmartines

Description

@davidwmartines

Proto.Cluster.Kubernetes 1.7.0

When my app is built with <PublishAot>true</PublishAot> and using Kubernetes cluster provider I am getting the error below. It appears this is due to reflection based json serialization in the KubernetesClient. Is there any workaround, or is Aot not supported with Kubernetes currently?

warn: Proto.Cluster.Kubernetes.KubernetesProvider[0]
      Failed to register service
      System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'k8s.Models.V1Pod'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
       ---> System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'k8s.Models.V1Pod'.
         --- End of inner exception stack trace ---
         at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack&, Utf8JsonReader&, NotSupportedException) + 0x2bf
         at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader&, Type, JsonSerializerOptions, ReadStack&, T&) + 0x695
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader&, Type, JsonSerializerOptions, ReadStack&, T&, Boolean&) + 0x235
         at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader&, JsonSerializerOptions, ReadStack&) + 0x345
         at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState&, JsonReaderState&, ReadStack&) + 0xf7
         at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Stream) + 0x109
         at k8s.Kubernetes.<CreateResultAsync>d__46`1.MoveNext() + 0x249
      --- 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.<ICoreV1Operations_ReadNamespacedPodWithHttpMessagesAsync>d__116`1.MoveNext() + 0x3f6
      --- 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.<k8s-ICoreV1Operations-ReadNamespacedPodWithHttpMessagesAsync>d__117.MoveNext() + 0xf3
      --- 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.CoreV1OperationsExtensions.<ReadNamespacedPodAsync>d__105.MoveNext() + 0xf2
      --- 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 Proto.Cluster.Kubernetes.KubernetesProvider.<RegisterMemberInner>d__21.MoveNext() + 0x1e5
      --- 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 Proto.Utils.Retry.<Try>d__4.MoveNext() + 0xf4


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