Skip to content

Refactor storePodsNamespacer.List()#25895

Merged
k8s-github-robot merged 1 commit intokubernetes:masterfrom
mml:storePodNamespacer.List
May 26, 2016
Merged

Refactor storePodsNamespacer.List()#25895
k8s-github-robot merged 1 commit intokubernetes:masterfrom
mml:storePodNamespacer.List

Conversation

@mml
Copy link
Copy Markdown
Contributor

@mml mml commented May 19, 2016

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.

@mml mml added this to the v1.3 milestone May 19, 2016
@mml mml added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. labels May 19, 2016
@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 19, 2016
@lavalamp
Copy link
Copy Markdown
Contributor

code change looks like a big improvement. Should I be asking for a new test?

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 19, 2016

@lavalamp what do you have in mind?

@lavalamp
Copy link
Copy Markdown
Contributor

@mml maybe of the brute force list block, since I think it probably wasn't getting used/exercised at all before?

@mml mml force-pushed the storePodNamespacer.List branch from 5271dbf to 074953f Compare May 19, 2016 22:23
@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 19, 2016

@lavalamp test added, and I verified that it failed on upstream/master. PTAL

@k8s-github-robot k8s-github-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 19, 2016
@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 20, 2016

Huh.

Running tests for APIVersion: v1,extensions/v1beta1 with etcdPrefix: kubernetes.io/registry
+++ [0519 16:06:04] Running tests without code coverage
[...]
FAIL    k8s.io/kubernetes/test/integration  406.207s

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 20, 2016

@k8s-bot retest this please #25539

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 20, 2016

@k8s-bot test this issue: #25539

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 20, 2016

Well, this is a new one.

--- FAIL: TestReflectorResync (0.01s)
    reflector_test.go:380: exactly 2 iterations were expected, got: 3
[...]
FAIL
FAIL    k8s.io/kubernetes/pkg/client/cache  0.884s

Passes on my workstation. I'm running it in a loop overnight hoping for a repeat failure.

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 20, 2016

I ran this 1000 times last night with 0 failures.

@k8s-bot unit test this issue: #25964

@0xmichalis
Copy link
Copy Markdown
Contributor

storeReplicationControllersNamespacer seems to have the same problem

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 23, 2016

@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.

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 23, 2016

@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.

@mml
Copy link
Copy Markdown
Contributor Author

mml commented May 23, 2016

Updated again to fix #26107

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mml mml force-pushed the storePodNamespacer.List branch from 17cbb34 to 9a9c061 Compare May 24, 2016 21:11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return pods, err

I don't care myself, but some people find it less confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll make the change.

Would be nice to have a clear style guide and enforce it with a verify-* check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same for all

@lavalamp
Copy link
Copy Markdown
Contributor

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.
@mml mml force-pushed the storePodNamespacer.List branch from 9a9c061 to 1fee311 Compare May 26, 2016 00:19
@mml mml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2016
@k8s-github-robot
Copy link
Copy Markdown

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link
Copy Markdown

k8s-bot commented May 26, 2016

GCE e2e build/test passed for commit 1fee311.

@k8s-github-robot
Copy link
Copy Markdown

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 34a640d into kubernetes:master May 26, 2016
k8s-github-robot pushed a commit that referenced this pull request Aug 17, 2016
Automatic merge from submit-queue

Implement DisruptionController.

Part of #12611

This currently also includes a pending commit from #25895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants