csharp icon indicating copy to clipboard operation
csharp copied to clipboard

KubernetesClient.Aot args IList<string> serialization error

Open SGStino opened this issue 1 year ago • 4 comments

Describe the bug If a kubernetes client config contains string lists (for example, at users[*].user.exec.args), the yaml serializer throws that it can't deserialize the node into IList.

No node deserializer was able to deserialize the node into type System.Collections.Generic.IList`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e

Kubernetes C# SDK Client Version 14.0.2

Server Kubernetes Version N\A

Dotnet Runtime Version net8

To Reproduce Create a config that contains a user that needs to "exec" with arguments, for example kube oidc login (see KubeConfig)

Expected behavior Being able to deserialize the config, including the args list.

KubeConfig

...
users:
- name: oidc-prod
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - oidc-login
      - get-token
      - --oidc-issuer-url=https://identity
      - --oidc-client-id=k8s
      - --oidc-client-secret=topsecret
      command: kubectl 
      interactiveMode: IfAvailable
      provideClusterInfo: false
...

Where do you run your app with Kubernetes SDK (please complete the following information): Reproducable in RoslynPad or dotnet console application:

#r "nuget: KubernetesClient.Aot, 14.0.2"
using k8s;
using k8s.Models;
var clientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();

Additional context in the JsonSerializationContext for AOT source generation you'd have to include [JsonSerializable(typeof(IList<string>))], my guess would be that there is something similar for YamlDotNet?

SGStino avatar Jul 09 '24 13:07 SGStino

seems so, would you like to send a pr to fix it? or i will pick it this weekend

tg123 avatar Jul 11 '24 20:07 tg123

We could pick it up, but, at first glance I don't really see where that would be done in YamlDotNet. There doesn't seem to be a serialization context like in System.Text.Json? Any suggestion as to where to look? Haven't done any AOT with Yaml so far yet.

SGStino avatar Jul 12 '24 09:07 SGStino

It seems that all the YamlSerializeableAttributes aren't required on the StaticContext and that it still works for most of the types.

But adding [YamlSerializeableAttribute(typeof(IList<string>))] makes the Source generator generate invalid code and it won't compile anymore. only [YamlSerializeableAttribute(typeof(string[])] generates code that compiles, but that would require updating the kubernetes client models, which wouldn't be desirable...

It might be related to https://github.com/aaubry/YamlDotNet/issues/740#issuecomment-1360163696

And if i'm reading this: https://github.com/aaubry/YamlDotNet/issues/884 it might fix itself in a few days.

SGStino avatar Jul 12 '24 13:07 SGStino

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Oct 10 '24 14:10 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Nov 09 '24 14:11 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Dec 09 '24 14:12 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Dec 09 '24 14:12 k8s-ci-robot