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

🌱 controllers: fix ProviderServiceAccount tests to create objects on-demand #2983

Merged

Conversation

chrischdi
Copy link
Member

What this PR does / why we need it:

This PR changes the controllers tests for serviceaccount_controller and servicediscovery_controller to only create the objects which are required, instead of creating all and deleting the ones not required.

This solves a race condition for the serviceaccount_controller related test cases for the following cases:

In case of this tests, the serviceaccount_controller could already have reconciled once successfully and added a successful ProviderServiceAccountsReadyCondition before the tests have deleted the relevant objects.

This gets reproducible by adding a time.Sleep(time.Second) before the deletion, e.g. at:

This solves the flake we heavily see on release-1.7:

image

E.g.:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

/hold

I want to do final verification locally

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 8, 2024
@chrischdi
Copy link
Member Author

/cherry-pick release-1.10

@k8s-infra-cherrypick-robot

@chrischdi: once the present PR merges, I will cherry-pick it on top of release-1.10 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.10

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.

@chrischdi
Copy link
Member Author

/cherry-pick release-1.9

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 8, 2024
@k8s-infra-cherrypick-robot

@chrischdi: once the present PR merges, I will cherry-pick it on top of release-1.9 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.9

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.

@chrischdi
Copy link
Member Author

/cherry-pick release-1.8

@k8s-infra-cherrypick-robot

@chrischdi: once the present PR merges, I will cherry-pick it on top of release-1.8 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.8

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.

@chrischdi
Copy link
Member Author

/cherry-pick release-1.7

@k8s-infra-cherrypick-robot

@chrischdi: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.7

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 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 May 10, 2024
@chrischdi
Copy link
Member Author

/hold cancel

Works great also for release-1.7 (did a local manual cherry-pick).

Note: cherry-picker is expected to fail at least for 1.7, let's see which ones we have to manually cherry-pick

/assign @fabriziopandini @sbueringer

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 10, 2024
@chrischdi chrischdi added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 13, 2024
@sbueringer
Copy link
Member

Can you please also rename the misleading funcs? (xref: #2983 (comment))

createCluster, etc.

@sbueringer
Copy link
Member

Thx!

Very nice investigation! :)

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 2aff8a7284383da35f5aad0bbd078f9f718bf2b3

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 May 13, 2024
@k8s-ci-robot k8s-ci-robot merged commit b3d167f into kubernetes-sigs:main May 13, 2024
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone May 13, 2024
@k8s-infra-cherrypick-robot

@chrischdi: new pull request created: #2997

In response to this:

/cherry-pick release-1.9

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-infra-cherrypick-robot

@chrischdi: #2983 failed to apply on top of branch "release-1.8":

Applying: controllers: fix ProviderServiceAccount tests to create objects on-demand
Using index info to reconstruct a base tree...
M	controllers/serviceaccount_controller_intg_test.go
A	controllers/servicediscovery_controller_intg_test.go
A	internal/test/helpers/vmware/intg_test_context.go
Falling back to patching base and 3-way merge...
Auto-merging test/helpers/vmware/intg_test_context.go
CONFLICT (content): Merge conflict in test/helpers/vmware/intg_test_context.go
Auto-merging controllers/svcdiscovery_controller_intg_test.go
Auto-merging controllers/serviceaccount_controller_intg_test.go
CONFLICT (content): Merge conflict in controllers/serviceaccount_controller_intg_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 controllers: fix ProviderServiceAccount tests to create objects on-demand
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.8

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-infra-cherrypick-robot

@chrischdi: #2983 failed to apply on top of branch "release-1.7":

Applying: controllers: fix ProviderServiceAccount tests to create objects on-demand
Using index info to reconstruct a base tree...
M	controllers/serviceaccount_controller_intg_test.go
A	controllers/servicediscovery_controller_intg_test.go
A	internal/test/helpers/vmware/intg_test_context.go
Falling back to patching base and 3-way merge...
Auto-merging test/helpers/vmware/intg_test_context.go
CONFLICT (content): Merge conflict in test/helpers/vmware/intg_test_context.go
Auto-merging controllers/svcdiscovery_controller_intg_test.go
Auto-merging controllers/serviceaccount_controller_intg_test.go
CONFLICT (content): Merge conflict in controllers/serviceaccount_controller_intg_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 controllers: fix ProviderServiceAccount tests to create objects on-demand
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.7

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-infra-cherrypick-robot

@chrischdi: new pull request created: #2998

In response to this:

/cherry-pick release-1.10

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.

chrischdi added a commit to chrischdi/cluster-api-provider-vsphere that referenced this pull request May 14, 2024
…demand (kubernetes-sigs#2983)

* controllers: fix ProviderServiceAccount tests to create objects on-demand

* review fixes
chrischdi added a commit to chrischdi/cluster-api-provider-vsphere that referenced this pull request May 14, 2024
…demand (kubernetes-sigs#2983)

* controllers: fix ProviderServiceAccount tests to create objects on-demand

* review fixes
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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants