kubernetes / kube-openapi

Kubernetes OpenAPI spec generation & serving
Apache License 2.0
319 stars 208 forks source link

Thread safe cached #403

Closed apelisse closed 1 year ago

apelisse commented 1 year ago

Improve cached framework to be thread-safe. I was convinced by the following arguments:

  1. We can have multiple different entry points into the "get-chain", so it's possibly hard to properly secure all of them
  2. If the dependency tree ends-up having a diamond shape, we can't make multithreaded Get resolution without causing a race-condition (that feature is also added in the pull-request)
  3. It's unintuitive that "Get" needs to be protected, since it sounds like a read method rather than a write.

cc @Jefftree

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse

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: - ~~[OWNERS](https://github.com/kubernetes/kube-openapi/blob/master/OWNERS)~~ [apelisse] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
apelisse commented 1 year ago

Updated, PTAL

apelisse commented 1 year ago

OK I've made the test do something though the goal is not to test that they work, but merely that they are thread-safe internally.

Jefftree commented 1 year ago

OK I've made the test do something though the goal is not to test that they work, but merely that they are thread-safe internally.

+1 agree with this approach.

/lgtm /hold

Feel free to unhold whenever, but just in case you want another pair of eyes

apelisse commented 1 year ago

/hold cancel