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] Avoid thread.sleep usage instead semaphore as replacement #1943

Conversation

shharma-vipin
Copy link

@shharma-vipin shharma-vipin commented Oct 24, 2021

Avoided Thread.sleep() and rather used TimedSemphore() to perform waiting and then let task happen
PR is to fix one of the issue under this PR umbrella #1223

Committer: Vipin Sharma <sharmavipin1310@gmail.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shharma-vipin
To complete the pull request process, please assign yue9944882 after the PR has been reviewed.
You can assign the PR to them by writing /assign @yue9944882 in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 24, 2021
@shharma-vipin
Copy link
Author

/check-cla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 24, 2021
@shharma-vipin
Copy link
Author

/check-cla

1 similar comment
@shharma-vipin
Copy link
Author

/check-cla

@shharma-vipin shharma-vipin marked this pull request as draft October 24, 2021 04:56
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2021
@shharma-vipin shharma-vipin marked this pull request as ready for review October 24, 2021 04:56
@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 Oct 24, 2021
@shharma-vipin
Copy link
Author

/check-cla

@shharma-vipin
Copy link
Author

Need help with cla/linuxfoundation. Not able to clear that github stage.

@shharma-vipin shharma-vipin marked this pull request as draft October 24, 2021 05:05
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2021
@shharma-vipin shharma-vipin marked this pull request as ready for review October 24, 2021 05:15
@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 Oct 24, 2021
@shharma-vipin
Copy link
Author

/assign @yue9944882

@shharma-vipin
Copy link
Author

/unassign @yue9944882

@shharma-vipin
Copy link
Author

/check-cla

1 similar comment
@shharma-vipin
Copy link
Author

/check-cla

@shharma-vipin
Copy link
Author

cla bot - showing this as an error - "cla/linuxfoundation — shharma-vipin authorized, but 1 other problem".
However I am not able to locate logs to figure out the issue with this PR.
Any help on this ?

@shharma-vipin shharma-vipin changed the title [fix] avoided thread.sleep usage and added semaphore as replacement [fix] Avoid thread.sleep usage and added semaphore as replacement Oct 24, 2021
@shharma-vipin shharma-vipin changed the title [fix] Avoid thread.sleep usage and added semaphore as replacement [fix] Avoid thread.sleep usage instead semaphore as replacement Oct 24, 2021
@shharma-vipin
Copy link
Author

/check-cla

@shharma-vipin shharma-vipin marked this pull request as draft October 24, 2021 12:45
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2021
@shharma-vipin
Copy link
Author

/check-sla

@shharma-vipin shharma-vipin marked this pull request as ready for review October 24, 2021 12:45
@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 Oct 24, 2021
@gjkim42
Copy link

gjkim42 commented Oct 24, 2021

I think one of your commits has a different email address?
It would be better to squash those commits into one commit and set the author and the email address properly.

@brendandburns
Copy link
Contributor

Thank you for sending in the PR.

However, there is not much difference between using a TimedSemaphore and just using Thread.sleep(...)

For this particular test, the right way to fix it would be to inject a mock Bandwidth object into the rate limiter and be able to adjust time without sleeping.

However, looking at the code I'm pretty skeptical that this test will ever be racy, so it's probably not worth the effort.

There are a number of other places e.g.
https://github.com/kubernetes-client/java/blob/master/util/src/test/java/io/kubernetes/client/informer/cache/SharedProcessorTest.java#L55

Which would be better to fix if you want to fix one of them.

Thanks!

@yue9944882
Copy link
Member

@shharma-vipin ur commit 7d13b01 is authored by vipinsharma@Vipins-MacBook-Pro.local which is why ur pr fails cla check

@shharma-vipin
Copy link
Author

shharma-vipin commented Oct 26, 2021

As per one of the review comment & looking at effectiveness of this change set, closing this PR

@shharma-vipin shharma-vipin deleted the fix_bucket_ratelimiter_test branch October 26, 2021 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. 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.

5 participants