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

fix: add lock for kubernetesOpenAPIVersion #4967

Conversation

pmalek
Copy link
Contributor

@pmalek pmalek commented Jan 10, 2023

Ideally we'd introduce a fully fledged fix that avoids usage of globals but that might be more involved hence this simple fix.

Partially fixes: #4824.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 10, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @pmalek!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. 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-sigs/kustomize 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
Copy link
Contributor

Hi @pmalek. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 10, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 10, 2023
@koba1t
Copy link
Member

koba1t commented Jan 11, 2023

Hi @pmalek.
Thanks for your contribution!

I think we need to check in the test whether #4824 is fixed.
Could you add test cases to check that problem is fixed?

/cc @KnVerey

@pmalek
Copy link
Contributor Author

pmalek commented Jan 14, 2023

Hi @pmalek. Thanks for your contribution!

I think we need to check in the test whether #4824 is fixed. Could you add test cases to check that problem is fixed?

Hi @koba1t 👋

What we're trying to test here is a data race which is tricky to deterministically ensure in tests.

I can submit a test that would spin 2 (or more?) goroutines which would call SetSchema/ResetOpenAPI for a while and verify that it didn't panic but in order for this to make sense we'd need to add a -race flag to go test command invocation. I'd assume this is the relevant one:

go test -v -cover ./...

Can you give some guidance on this?

@koba1t
Copy link
Member

koba1t commented Jan 17, 2023

Hi @pmalek!

That is the right line to edit the test flag.

Can you give some guidance on this?

I think we just edit the kyaml/Makefile file.

@KnVerey
Copy link
Contributor

KnVerey commented Jan 23, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 23, 2023
@pmalek pmalek force-pushed the add-lock-for-kubernetesOpenAPIVersion branch from d035931 to 5384da3 Compare January 24, 2023 13:25
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 24, 2023
@pmalek
Copy link
Contributor Author

pmalek commented Jan 24, 2023

I've added a test that tests this (to an extent possible). I'm not particularly fond of this solution but hey! it helps with the data race problem.

@pmalek pmalek force-pushed the add-lock-for-kubernetesOpenAPIVersion branch from 5384da3 to d8cc1dd Compare January 24, 2023 15:20
Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Thanks for adding a test! I confirmed that it fails pretty reliably on master; it just needs a real name, please. :)

kyaml/openapi/openapi_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey, pmalek

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 Jan 24, 2023
@KnVerey KnVerey added this to the v5.0.0 milestone Jan 24, 2023
@pmalek pmalek force-pushed the add-lock-for-kubernetesOpenAPIVersion branch from d8cc1dd to 43de3d9 Compare January 24, 2023 18:08
@KnVerey
Copy link
Contributor

KnVerey commented Jan 24, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 24, 2023
@KnVerey
Copy link
Contributor

KnVerey commented Jan 24, 2023

The test failures are unrelated and fixed by #4995

@koba1t
Copy link
Member

koba1t commented Jan 25, 2023

/lgtm

Could you try to rebase master to fix test failures?

@pmalek pmalek force-pushed the add-lock-for-kubernetesOpenAPIVersion branch from 43de3d9 to 547462e Compare January 25, 2023 14:14
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2023
@pmalek
Copy link
Contributor Author

pmalek commented Jan 25, 2023

/lgtm

Could you try to rebase master to fix test failures?

Done

@KnVerey
Copy link
Contributor

KnVerey commented Jan 26, 2023

I'm so sorry, but an external change caused another failure on master that was fixed in #5004 . Can you please rebase one last time? I swear this isn't normal. 😅

@pmalek pmalek force-pushed the add-lock-for-kubernetesOpenAPIVersion branch from 547462e to f7c3fce Compare January 27, 2023 08:41
@pmalek
Copy link
Contributor Author

pmalek commented Jan 27, 2023

I'm so sorry, but an external change caused another failure on master that was fixed in #5004 . Can you please rebase one last time? I swear this isn't normal. 😅

No worries 🙃 Done.

@KnVerey
Copy link
Contributor

KnVerey commented Jan 28, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 28, 2023
@k8s-ci-robot k8s-ci-robot merged commit 58defe3 into kubernetes-sigs:master Jan 28, 2023
@emirot
Copy link
Contributor

emirot commented Apr 15, 2024

@pmalek why partially ?

@pmalek pmalek deleted the add-lock-for-kubernetesOpenAPIVersion branch April 20, 2024 12:56
@pmalek
Copy link
Contributor Author

pmalek commented Apr 20, 2024

@emirot Partially because IMHO there should be no need to use globals.

On top of that as I look at this now there are places where globalSchema is accessed without a lock: e.g. in

func AddDefinitions(definitions spec.Definitions) {

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: data race when calling Kustomizer.Run() from multiple goroutines
5 participants