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

Honor starting resourceVersion in watch cache #24208

Merged

Conversation

ncdc
Copy link
Member

@ncdc ncdc commented Apr 13, 2016

Compare the requested resourceVersion to each event's resourceVersion to ensure events that occurred
in the past are not sent to the client.

Fixes #24194

cc @liggitt @wojtek-t

@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

I'd like to add a unit test for this but I've got a question about it at #24194 (comment)

@@ -555,6 +555,10 @@ func (c *cacheWatcher) process(initEvents []watchCacheEvent) {
if !ok {
return
}
if event.ResourceVersion <= resourceVersion {
Copy link
Member

Choose a reason for hiding this comment

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

can we just make the send conditional?

// only send events newer than resourceVersion
if event.ResourceVersion > resourceVersion {
  c.sendWatchCacheEvent(event)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

@k8s-github-robot
Copy link

Labelling this PR as size/S

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed labels Apr 13, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit edd8c916d1fe65b75da23567ee419384e9d0e8ae.

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test failed for commit 1703d32c2edbfc40edab8d00cbe7e5e5fcc374fe.

Please reference the list of currently known flakes when examining this failure. If you request a re-test, you must reference the issue describing the flake.

@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

@k8s-bot e2e test this github issue: #23974

@wojtek-t wojtek-t added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Apr 13, 2016
@wojtek-t wojtek-t assigned wojtek-t and unassigned smarterclayton Apr 13, 2016
@timothysc
Copy link
Member

Are there a positive and negative checks in the tests for this?

@wojtek-t
Copy link
Member

Code changes LGTM - we just need some test for it.

@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

@timothysc will have units for it - just need to figure out how to write them w/o having them flake or take 30+ seconds

@wojtek-t
Copy link
Member

@timothysc - see #24194 for discussion about test

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 1703d32c2edbfc40edab8d00cbe7e5e5fcc374fe.

podFoo := makeTestPod("foo")
fooCreated := updatePod(t, etcdStorage, podFoo, nil)

// Set up Watch starting at fooCreated.ResourceVersion + 1
Copy link
Member

Choose a reason for hiding this comment

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

update comment

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@k8s-github-robot
Copy link

Labelling this PR as size/M

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 13, 2016
@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

@timothysc test added, PTAL

@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

Hmm the test might still pass without my fix... investigating.

@ncdc
Copy link
Member Author

ncdc commented Apr 13, 2016

Fixed the test. Helps if you generate events for the right etcd path :-)

fooCreated := updatePod(t, etcdStorage, podFoo, nil)

// Set up Watch starting at fooCreated.ResourceVersion + 10
rv, err := storage.ParseWatchResourceVersion(fooCreated.ResourceVersion)
Copy link
Member

Choose a reason for hiding this comment

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

this logic could probably be reduced but it's a test so whatevers... re: parse + addition + convert

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I considered that but decided to be lazy 😄

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

Copy link
Member

Choose a reason for hiding this comment

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

I would do the same :)

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 2f2ee168f96411290b19a9af3ddb283e51cc9b73.

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 62a2ee0450deb7b9072038643729f72f67aa1d45.

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 0c23527da2f423904664e5bcce309ddc69da8b68.

case <-time.After(wait.ForeverTestTimeout):
t.Errorf("timed out waiting for event")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

could nit, not going to, will let @wojtek-t decide.

@wojtek-t
Copy link
Member

@ncdc - can you please squash commits and rebase?

Compare the requested resourceVersion to each event's resourceVersion to ensure events that occurred
in the past are not sent to the client.
@ncdc ncdc force-pushed the watch-cache-check-starting-rv branch from 21f6fe0 to 049e63d Compare April 14, 2016 13:37
@ncdc
Copy link
Member Author

ncdc commented Apr 14, 2016

Rebased & squashed

@wojtek-t wojtek-t added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2016
@wojtek-t
Copy link
Member

LGTM - thanks for fixing this!

@k8s-cherrypick-bot
Copy link

Removing label cherrypick-candidate because no release milestone was set. This is an invalid state and thus this PR is not being considered for cherry-pick to any release branch. Please add an appropriate release milestone and then re-add the label.

@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test failed for commit 21f6fe03ffc9e5a09c2bf50d6bd659e4c002c936.

Please reference the list of currently known flakes when examining this failure. If you request a re-test, you must reference the issue describing the flake.

@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test passed for commit 049e63d.

@k8s-github-robot
Copy link

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

@k8s-bot
Copy link

k8s-bot commented Apr 14, 2016

GCE e2e build/test passed for commit 049e63d.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit d800dca into kubernetes:master Apr 14, 2016
@ncdc ncdc added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 18, 2016
@roberthbailey roberthbailey added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Apr 19, 2016
zmerlynn added a commit that referenced this pull request Apr 20, 2016
…pstream-release-1.2

Automated cherry pick of #24208
shyamjvs pushed a commit to shyamjvs/kubernetes that referenced this pull request Dec 1, 2016
…f-#24208-upstream-release-1.2

Automated cherry pick of kubernetes#24208
@ncdc ncdc deleted the watch-cache-check-starting-rv branch February 13, 2017 17:24
shouhong pushed a commit to shouhong/kubernetes that referenced this pull request Feb 14, 2017
…f-#24208-upstream-release-1.2

Automated cherry pick of kubernetes#24208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.