kubernetes-client / csharp

Officially supported dotnet Kubernetes Client library
Apache License 2.0
1.1k stars 296 forks source link

Support for YamlDotNet 16.0.0 #1573

Closed toby-butchart-starfish closed 1 month ago

toby-butchart-starfish commented 3 months ago

Describe the bug Hi guys, I was wondering if there were plans to support YamlDotNet v 16.0.0? It looks like they have made some breaking changes in the latest release: https://github.com/aaubry/YamlDotNet/releases/tag/v16.0.0 specifically to ReadYaml and WriteYaml in IYamlTypeConverter.cs leaving any descendant in the KubernetesClient library broken (i.e., IntOrStringYamlConverter).

Let me know if you need any more information.

Dotnet Runtime Version net8

To Reproduce

Expected behavior Connection to succeed

Where do you run your app with Kubernetes SDK (please complete the following information):

tg123 commented 3 months ago

let me take a look

aDisplayName commented 3 months ago

Based on the error message, one possible solution is to provide both forms of implementations of IYamlTypeConverter, so host project can freely choose YamlDotNet 16.x or older version

IvanJosipovic commented 2 months ago

I recently upgraded one of my projects to YamlDotNet 16, its quite easy, https://github.com/IvanJosipovic/YamlDotNet.System.Text.Json/commit/fa5963fd7a900d6977f40a0af08afcc088db3dd9

I can do a PR for this if needed. Additionally, I don't see much value in making these converters backward compatible.

tg123 commented 2 months ago

thanks @IvanJosipovic, please. i was too busy recently

mmgerald commented 2 months ago

Thanks to everyone. @tg123 Is it possible to trigger a release. Also https://github.com/buehler/dotnet-operator-sdk is broken if v16 of YamlDotNet is used.

See also https://github.com/buehler/dotnet-operator-sdk/issues/797

cdavernas commented 1 month ago

Any news regarding the release? I'm facing the issue, too.

tg123 commented 1 month ago

will kick a release for 1.31 soon

mmgerald commented 1 month ago

Thank you!

IvanJosipovic commented 1 month ago

This was fixed in https://www.nuget.org/packages/KubernetesClient/14.0.9

cdavernas commented 1 month ago

@IvanJosipovic apparently not, it's the version I'm using and it throws NotImplementedExceptions at startup

IvanJosipovic commented 1 month ago

@IvanJosipovic apparently not, it's the version I'm using and it throws NotImplementedExceptions at startup

Check the references in nuget.org, you may have another dependency forcing the downgrade. image

cdavernas commented 1 month ago

you may have another dependency forcing the downgrade

@IvanJosipovic AFAIK I do not. All packages are up to latest version.

If you want, you can easily repro the issue by starting Synapse's API server on the following branch: https://github.com/serverlessworkflow/synapse/tree/feat-k8s-container-platform/src/api/Synapse.Api.Server

Removing the KubernetesClient package (and all related classes) from the solution "fixes" the issue.

IvanJosipovic commented 1 month ago

you may have another dependency forcing the downgrade

@IvanJosipovic AFAIK I do not. All packages are up to latest version.

If you want, you can easily repro the issue by starting Synapse's API server on the following branch: https://github.com/serverlessworkflow/synapse/tree/feat-k8s-container-platform/src/api/Synapse.Api.Server

Removing the KubernetesClient package (and all related classes) from the solution "fixes" the issue.

Just launched your branch, the error is:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Neuroglia.Serialization.Yaml.YamlSerializer' threw an exception.
 ---> System.TypeLoadException: Method 'ReadYaml' in type 'Neuroglia.Serialization.Yaml.JsonNodeTypeConverter' from assembly 'Neuroglia.Serialization.YamlDotNet, Version=4.15.3.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Neuroglia.Serialization.Yaml.YamlSerializer.<>c.<.cctor>b__8_0(SerializerBuilder serializer)
   at Neuroglia.Serialization.Yaml.YamlSerializer..cctor() in /home/runner/work/framework/framework/src/Neuroglia.Serialization.YamlDotNet/Services/YamlSerializer.cs:line 90
   --- End of inner exception stack trace ---
   at Neuroglia.Serialization.IServiceCollectionExtensions.<>c.<AddYamlDotNetSerializer>b__0_0(IYamlSerializerBuilder builder) in /home/runner/work/framework/framework/src/Neuroglia.Serialization.YamlDotNet/Extensions/IServiceCollectionExtensions.cs:line 39
   at Neuroglia.Serialization.IServiceCollectionExtensions.AddYamlDotNetSerializer(IServiceCollection services, Action`1 setup, ServiceLifetime lifetime) in /home/runner/work/framework/framework/src/Neuroglia.Serialization.YamlDotNet/Extensions/IServiceCollectionExtensions.cs:line 42
   at Synapse.IServiceCollectionExtensions.AddSynapse(IServiceCollection services, IConfiguration configuration) in C:\Users\ivanj\Downloads\synapse-feat-k8s-container-platform\synapse-feat-k8s-container-platform\src\core\Synapse.Core.Infrastructure\Extensions\IServiceCollectionExtensions.cs:line 49
   at Program.<Main>$(String[] args) in C:\Users\ivanj\Downloads\synapse-feat-k8s-container-platform\synapse-feat-k8s-container-platform\src\api\Synapse.Api.Server\Program.cs:line 25
   at Program.<Main>(String[] args)

Looks like you have your own converter Neuroglia.Serialization.Yaml.JsonNodeTypeConverter which needs to be updated.

See here, https://github.com/neuroglia-io/framework/blob/main/src/Neuroglia.Serialization.YamlDotNet/Neuroglia.Serialization.YamlDotNet.csproj

cdavernas commented 1 month ago

@IvanJosipovic Sorry about that, in my dev setup I had manually updated the dependencies of the incriminated package. I'll properly update it, publish it and test it. I'll keep you posted!

In the meanwhile, thanks for both your patience and attention 🙏

cdavernas commented 1 month ago

@IvanJosipovic I updated all packages and everything is working as expected!!! Many thanks ❤️