-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
[bug]: Mutating WebHook is throwing a Json exception #531
Comments
Hi. We are also hitting a similar issue, but with a Validating web hook. Could this be caused by this change, please? In this release the |
Maybe that 'M' stands for Is it possible that this change caused this issue? A StreamReader was changed into: var review = KubernetesJson.Deserialize<AdmissionReview<TEntity>>(context.Request.Body.ToString()); |
In this case it could be fixed by using one of the |
Yes and thanks @anekdoti I will create a PR with the following fix: using var reader = new StreamReader(context.Request.Body);
var requestBody = await reader.ReadToEndAsync();
var review = KubernetesJson.Deserialize<AdmissionReview<TEntity>>(requestBody); |
Describe the bug
With the latest version the mutating webhook doesn't get called correctly.
Here's the error that it is returning
I have narrowed it down to
dotnet-operator-sdk/src/KubeOps/Operator/Webhooks/IAdmissionWebhook{TEntity, TResult}.cs
Line 110 in a0a582d
It is calling ToString on the body stream. This returns the type name, not the actual content of the stream.
To reproduce
Use the template,
Create a mutating webhook for a pod
Deploy
Create a pod
Expected behavior
Not to throw the error and allow the mutating webhook to work
Screenshots
No response
Additional Context
I also had to modify the resulting dockerfile to reference the 6.0 docker images instead of latest.
The text was updated successfully, but these errors were encountered: