-
Notifications
You must be signed in to change notification settings - Fork 296
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 7.x patching broken #772
Comments
starting from 7.x, the sdk switched to |
This is the code we use to make the call: var patch = new JsonPatchDocument<V1Pod>(); //Microsoft.AspNetCore.JsonPatch
patch.Replace(x => x.Metadata.Labels, labels);
await kubernetes.PatchNamespacedPodAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), podName, podNamespace); Is there anything we should change on our end here? |
you may want to take a look at https://www.nuget.org/packages/JsonPatch.Net/ here is test using it csharp/tests/E2E.Tests/MnikubeTests.cs Line 121 in 8f4ee45
|
I also discovered the behavior change (serializer change from Newtonsoft to System.Text.Json). Yes, the problem can be worked around by using another third party supporting it, but that can also be solved serializing with Newtonsoft before the k8s.csharp call: var patch = new JsonPatchDocument<V1Pod>();
patch.ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
patch.Replace(x => x.Metadata.Labels, labels);
var patchString = Newtonsoft.Json.JsonConvert.SerializeObject(patch);
await kubernetes.PatchNamespacedPodAsync(new V1Patch(patchString, V1Patch.PatchType.JsonPatch), podName, podNamespace); The ContractResolver is needed, because previously API object were decorated with Newtonsoft attributes containing the camelcase name, and it is now using System.Text.Json attributes. Still, it is a bit sad to change the serializer on a Patch object to a serializer that doesn't support Json Patch. |
asynkron/protoactor-dotnet#1416
After upgrading to KubernetesClient 7.0.8, we are seeing the following error returned from k8s when trying to patch pod labels:
After adding a delegating logger to the HttpClient, we are seeing this payload being sent:
Downgrading to KubernetesClient 6.0.8 works, and does not have this invalid extra entry:
The text was updated successfully, but these errors were encountered: