Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not cache config if not explicitly set #413

Conversation

phisco
Copy link
Contributor

@phisco phisco commented May 8, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #352
Fixes #384

Based on #396

Special notes for your reviewer:

Based on #396, but attempting to solve #396 (comment).

This way we won't have any concurrent writes to the config client, as we are not caching it, the internal client is just for user-injected clients, so that a user can continue avoiding to provide a kubeconfig altogether if not needed. We might want to adjust naming.

Does this PR introduce a user-facing change?

The client won't be cached anymore, I wouldn't call it a user-facing change.

Additional documentation e.g., Usage docs, etc.:


Fricounet and others added 7 commits April 8, 2024 17:46
This commit fixes a bug where the config object was shared between tests.
When running tests in parallel, it was then impossible to rely on fields
like the namespace because they could have been overwritten by another
test. Also, it led to tests using `-race` to fail because the shared
config.klient object that were updating the same fields when initializing
the client.

This commit creates a new `deepCopyConfig` method that allows to create
a deep copy of the config object. This way, each test can have its own
without impacting the others. Now the config has the following lifecycle:
- It is created when a testEnv is created
- Each test uses a child testEnv that inherits the main testEnv's config
- Each feature uses a child testEnv that inherits the test's testEnv's config

This way, a feature inherits all the changes made in BeforeEach functions
while not impacting the other features.
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 8, 2024
@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label May 8, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 8, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @phisco. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 8, 2024
@vladimirvivien
Copy link
Contributor

/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 May 9, 2024
@phisco
Copy link
Contributor Author

phisco commented May 12, 2024

/retest

@phisco
Copy link
Contributor Author

phisco commented May 23, 2024

@vladimirvivien, can you trigger the tests? 🙏

@phisco
Copy link
Contributor Author

phisco commented May 28, 2024

trying pinging @harshanarayana 🙏 😬

@harshanarayana
Copy link
Contributor

Looking into it @phisco

@phisco phisco marked this pull request as ready for review May 29, 2024 12:38
@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 May 29, 2024
@phisco
Copy link
Contributor Author

phisco commented May 29, 2024

/retest

@harshanarayana
Copy link
Contributor

@phisco @Fricounet Do we still need to keep #396 alive?

@phisco
Copy link
Contributor Author

phisco commented May 31, 2024

Didn't want to hijack the original pr, just wanted to see if it broke tests, I'm fine closing this one and porting only my commit to #389 🙏

Copy link
Contributor

@Fricounet Fricounet left a comment

Choose a reason for hiding this comment

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

@phisco I do not mind if we merge this one instead since it already has all the changes

@harshanarayana
Copy link
Contributor

/lgtm

@vladimirvivien @cpanato mind taking a second look on this ?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 26, 2024
@cpanato
Copy link
Member

cpanato commented Jun 26, 2024

/lgtm

@vladimirvivien
Copy link
Contributor

Thanks @phisco @harshanarayana @cpanato

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: phisco, vladimirvivien

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 Jul 8, 2024
@k8s-ci-robot k8s-ci-robot merged commit d0da124 into kubernetes-sigs:main Jul 8, 2024
4 checks passed
@phisco
Copy link
Contributor Author

phisco commented Jul 8, 2024

And thanks @Fricounet for the initial implementation!

# for free to join this conversation on GitHub. Already have an account? # 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. kind/bug Categorizes issue or PR as related to a bug. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

Do not share config across tests Calling Config's Client() in tests running parallel yields a data race
6 participants