Refactor storePodsNamespacer.List()#25895
Conversation
|
code change looks like a big improvement. Should I be asking for a new test? |
|
@lavalamp what do you have in mind? |
|
@mml maybe of the brute force list block, since I think it probably wasn't getting used/exercised at all before? |
5271dbf to
074953f
Compare
|
@lavalamp test added, and I verified that it failed on upstream/master. PTAL |
|
Huh. |
|
Well, this is a new one. Passes on my workstation. I'm running it in a loop overnight hoping for a repeat failure. |
|
storeReplicationControllersNamespacer seems to have the same problem |
|
@Kargakis I see that now. There's also inconsistency. storePodsNamespacer returns a PodList, but storeReplicationControllerNamespacer returns []ReplicationController. Glancing at the rest of the file, I can't tell which is the idiom we want to use. (A type-parameterized way to define this interface would be nice. I guess we could do that with Yet More Codegen.) @lavalamp please hold off on review. I'll go ahead and test/fix the ReplicationController implementation in the same way. |
|
@lavalamp OK PTAL. I recommend looking at each commit separately. I will squash once the review is done. In the end, I realized upon looking at the way storeReplicationControllerNamespacer.List was implemented that the simple control flow works pretty easily as long as you never touch the return values until you get into one of the three cases. Both functions are exactly the same now. I think I uncovered yet another bug, though, which I'll file a new issue about. |
ca2fcd6 to
bd5dcc8
Compare
|
Updated again to fix #26107 |
pkg/client/cache/listers.go
Outdated
There was a problem hiding this comment.
I am not sure this is optimal. At the very least, you should add a comment explaining why this needs to happen. Unfortunately named return values don't help much either.
17cbb34 to
9a9c061
Compare
pkg/client/cache/listers.go
Outdated
There was a problem hiding this comment.
return pods, err
I don't care myself, but some people find it less confusing.
There was a problem hiding this comment.
I'll make the change.
Would be nice to have a clear style guide and enforce it with a verify-* check.
pkg/client/cache/listers.go
Outdated
|
lgtm-- squash & add label yourself. |
Refactor storePodsNamespacer.List() and storeReplicationContollersNamespacer.List(). They are the same function, just with different signatures. This fixes a bug where, when we fell back on a brute force approach, we were still returning an error. Also change to explicit return without named return values.
9a9c061 to
1fee311
Compare
|
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
|
GCE e2e build/test passed for commit 1fee311. |
|
Automatic merge from submit-queue |
This fixes a bug in the previous version where, when we fell back on a
brute force approach, we were still returning an error.
It also clarifies the flow control into 3 distinct cases. The cases
don't share variables any more, which makes mistakes like the one
mentioned above harder.