Skip to content
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

KubernetesClient.Aot args IList<string> serialization error #1570

Open
SGStino opened this issue Jul 9, 2024 · 5 comments
Open

KubernetesClient.Aot args IList<string> serialization error #1570

SGStino opened this issue Jul 9, 2024 · 5 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@SGStino
Copy link

SGStino commented Jul 9, 2024

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?

@tg123
Copy link
Member

tg123 commented Jul 11, 2024

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

@SGStino
Copy link
Author

SGStino commented Jul 12, 2024

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
Copy link
Author

SGStino commented Jul 12, 2024

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 aaubry/YamlDotNet#740 (comment)

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

@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 10, 2024
@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants