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

🐛 Add CleanupAndWait call for flaky ClusterClass test #7589

Conversation

killianmuldoon
Copy link
Contributor

Add a DeleteAndWait function to our test package which allows waiting until an object is deleting before moving on.

Fixes flake in https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/7587/pull-cluster-api-test-main/1595021734782701568

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 22, 2022
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 22, 2022
@@ -422,6 +422,28 @@ func (e *Environment) CreateAndWait(ctx context.Context, obj client.Object, opts
return nil
}

// DeleteAndWait deletes the given object and waits for it to be not available from the API Server.
func (e *Environment) DeleteAndWait(ctx context.Context, obj client.Object) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is very close to CleanupAndWait (takes one object instead of several) but I think it's worth adding just for the semantics of being closer to the normal client calls.

Copy link
Member

Choose a reason for hiding this comment

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

If the only difference is the vararg + the corresponding loop, let's please rename the existing func instead of introducing a new one

Copy link
Member

Choose a reason for hiding this comment

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

(is it the only difference?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't really rename it though, right - it would have to be deprecated. I'm fine with just using the existing function - I just always end up typing this in and wondering why it doesn't exist 😅

Copy link
Member

@fabriziopandini fabriziopandini Nov 22, 2022

Choose a reason for hiding this comment

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

+1 to rename current func to DeleteAndWait + adding

// Deprecated: use DeleteAndWait instead
func (e *Environment) CleanupAndWait(ctx context.Context, objs ...client.Object) error {
    return DeleteAndWait(ctx, objs...)
}

So we give proper notice to consumers

Copy link
Member

@sbueringer sbueringer Nov 23, 2022

Choose a reason for hiding this comment

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

In my opinion we don't have to deprecate as it's all just internal: internal/test/envtest/environment.go :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't realized this was in internal - I'll rename the func and update this PR.

Copy link
Member

@sbueringer sbueringer Nov 23, 2022

Choose a reason for hiding this comment

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

I assumed that you didn't noticed it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't actually create a 'Delete' function here as it interferes with the Client interface (answering probably how it ended up with this name in the first place), and I don't like having Cleanup paired with DeleteAndWait I think the easiest thing to do is just to continue to use cleanup as this is really not important 😄

Signed-off-by: killianmuldoon <kmuldoon@vmware.com>
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 23, 2022
@sbueringer sbueringer changed the title 🐛 Add DeleteAndWait function for flaky ClusterClass test 🐛 Add CleanupAndWait call for flaky ClusterClass test Nov 23, 2022
@sbueringer
Copy link
Member

Thx for the fix!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 23, 2022
@fabriziopandini
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 Nov 23, 2022
@k8s-ci-robot k8s-ci-robot merged commit cf62fe9 into kubernetes-sigs:main Nov 23, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.4 milestone Nov 23, 2022
@sbueringer
Copy link
Member

/cherry-pick release-1.3

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #7600

In response to this:

/cherry-pick release-1.3

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.

@sbueringer
Copy link
Member

/cherry-pick release-1.2

@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #7609

In response to this:

/cherry-pick release-1.2

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.

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants