-
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
AWS: Cache instances for ELB to avoid #45050 #47410
Conversation
f37f616
to
2ae83f0
Compare
@k8s-bot pull-kubernetes-kubemark-e2e-gce test this |
// cacheCriteria holds criteria that must hold to use a cached snapshot | ||
type cacheCriteria struct { | ||
MaxAge time.Duration | ||
HasInstances []awsInstanceID |
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.
Can we document this? What does HasInstances
do?
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.
Adding field docs
defer c.mutex.Unlock() | ||
|
||
// After() is technically broken by time changes until we have monotonic time | ||
if c.snapshot != nil && c.snapshot.timestamp.After(snapshot.timestamp) { |
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 may be worth writing c.snapshot.Younger(snapshot)
so as to encapsulate out internal time keeping?
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.
olderThan
proved clearer, but good suggestion!
if err != nil { | ||
return nil, err | ||
} | ||
} else { |
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.
nit: we can drop this else
altogether.
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 don't think we can - we only want to log if we are using a pre-existing snapshot
// After() is technically broken by time changes until we have monotonic time | ||
if c.snapshot != nil && c.snapshot.timestamp.After(snapshot.timestamp) { | ||
// If this happens a lot, we could run this function in a mutex and only return one result | ||
glog.Infof("Not caching concurrent DescribeInstances results") |
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 add the word aws
here..
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.
Done!
if c.snapshot != nil && c.snapshot.timestamp.After(snapshot.timestamp) { | ||
// If this happens a lot, we could run this function in a mutex and only return one result | ||
glog.Infof("Not caching concurrent DescribeInstances results") | ||
} else { |
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.
nit: we can drop the else.
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.
Not sure we can?
mostly looks good to me. Some minor style changes and nits. |
Pushed suggested changes (other than the if blocks) - please take a look @gnufied :-) |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gnufied, justinsb Associated issue: 45050 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
We maintain a cache of all instances, and we invalidate the cache whenever we see a new instance. For ELBs that should be sufficient, because our usage is limited to instance ids and security groups, which should not change. Fix kubernetes#45050
@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this |
Readding lgtm after trivial rebase |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
/retest |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
/retest |
Automatic merge from submit-queue (batch tested with PRs 47451, 47410, 47598, 47616, 47473) |
We maintain a cache of all instances, and we invalidate the cache
whenever we see a new instance. For ELBs that should be sufficient,
because our usage is limited to instance ids and security groups, which
should not change.
Fix #45050