-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Make list pods constant time #3083
Conversation
|
||
// Clock allows for injecting fake or real clocks into | ||
// the cache. | ||
type Clock interface { |
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.
This is duplicated in N places. we should really pull this out into a util. (and if you don't do that, this should probably be private.)
lastUpdate time.Time | ||
} | ||
|
||
type ipCache struct { |
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.
We should really extract this out into a generic cache.
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.
I added a TODO.
generally LGTM, small stuff to fix. thx! |
* move ip cache out of registry/pod * combine, rationalize, and move pod status logic * Fix unit and integration tests
Review comments addressed, going to try & run e2e now. |
|
||
// Every return path from this function stores a status in the cache, even | ||
// error cases. | ||
defer func() { |
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.
Please don't defer an anonymous function, I think it really hurts readability.
And in general this function is structured really weirdly.
How about extracting out a "constructNewStatus" function, and then only setting the status once at the end.
Basically LGTM, modulo fixing that one last function. |
8335733
to
8b588ac
Compare
add test for node existence cache behavior
LGTM, will merge on green... |
Make list pods constant time
This moves all status-computing logic to the pod cache, and also starts caching more things (like whether a node exists). Will make it easier in the future to move status computation into a separate process or all the way down to kubelet.
Fixes #2951
Fixes #2975
Improves #2922
I'm having troubles running e2e. Will figure that out tomorrow and also squash.