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

Lock usage of YamlDotNet Serializer and Deserializer #1544

Merged

Conversation

alxmitch
Copy link
Contributor

@alxmitch alxmitch commented Apr 3, 2024

YamlDotNet ISerializer / IDeserializer is not thread safe. This PR prevents concurrent use of the static serializers and deserializer in KubernetesYaml.

Addresses #1537

I have verified locally that this resolves the failing test in the linked PoC for the original issue, but have not included that test here as it didn't always reliably reproduce the issue. Keen for advice on appropriate testing around this change.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 3, 2024
Copy link

linux-foundation-easycla bot commented Apr 3, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: alxmitch / name: Alex Mitchell (09f8f20)

@k8s-ci-robot
Copy link
Contributor

Welcome @alxmitch!

It looks like this is your first PR to kubernetes-client/csharp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/csharp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 3, 2024
YamlDotNet ISerializer and IDeserializer are not thread-safe
@alxmitch alxmitch marked this pull request as ready for review April 3, 2024 05:23
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 3, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (master@d523291). Click here to learn what that means.

Files Patch % Lines
src/KubernetesClient/KubernetesYaml.cs 90.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1544   +/-   ##
=========================================
  Coverage          ?   61.46%           
=========================================
  Files             ?      103           
  Lines             ?     3065           
  Branches          ?      637           
=========================================
  Hits              ?     1884           
  Misses            ?     1181           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tg123
Copy link
Member

tg123 commented Apr 6, 2024

/LGTM

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alxmitch, tg123

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2024
@k8s-ci-robot k8s-ci-robot merged commit 7dad2f3 into kubernetes-client:master Apr 6, 2024
14 checks passed
@leonard520
Copy link

Hi, I am hitting the issue in our environment, and it is great to see the fix. May I know when will be a new release to include this fix? Thanks!

@tg123
Copy link
Member

tg123 commented Apr 25, 2024

13.0.37 is now published

@shenglol
Copy link
Contributor

shenglol commented May 3, 2024

I'm curious, why did we opt for lock instead of ThreadLocal? We're using this library within an ASP.NET Core service that handles concurrent requests. The concern with lock is the potential performance overhead it introduces.

@tg123
Copy link
Member

tg123 commented May 7, 2024

@shenglol for now, it is a quick, dirty and safest solution.

could you please send a pr of suggesting optimization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants