-
Notifications
You must be signed in to change notification settings - Fork 299
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
release lock as soon as finish using #1124
Conversation
✅ Deploy Preview for kubernetes-sigs-kueue ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @lowang-bh. 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 Once the patch is verified, the new status will be reflected by the 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. |
/lgtm |
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks ok, but I have a slight concern, that if there is a panic thrown between Lock and Unlock the lock will remain. It is usually not an issue if the code in between is very simple (sort of like here), but I have a feeling this code may evolve.
I would suggest to wrap the code into a function call and use Lock / defer Unlock pattern for the duration of the function. This could be either in a named function, like "snapshotQueueData", or an unnamed, like we do for example here:
kueue/client-go/informers/externalversions/factory.go
Lines 148 to 159 in 0ee53de
informers := func() map[reflect.Type]cache.SharedIndexInformer { | |
f.lock.Lock() | |
defer f.lock.Unlock() | |
informers := map[reflect.Type]cache.SharedIndexInformer{} | |
for informerType, informer := range f.informers { | |
if f.startedInformers[informerType] { | |
informers[informerType] = informer | |
} | |
} | |
return informers | |
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor, lowang-bh 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 |
/hold |
/lgtm cancel I'll leave the LGTM to @mimowo |
It sounds reasonable. The current implementation is a bit dangerous. |
Signed-off-by: lowang-bh <lhui_wang@163.com>
Have updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
LGTM label has been added. Git tree hash: f13b413e3b02927f9e0217fb3684daae0fabdce0
|
/hold cancel |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #1098
Special notes for your reviewer:
Does this PR introduce a user-facing change?