-
Notifications
You must be signed in to change notification settings - Fork 39k
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
etcd3/store: support TTL in Create, Update #23995
Conversation
@@ -118,10 +118,16 @@ func (s *store) Create(ctx context.Context, key string, obj, out runtime.Object, | |||
} | |||
key = keyWithPrefix(s.pathPrefix, key) | |||
|
|||
leaseOpt, err := s.createLeaseOpt(ctx, int64(ttl)) |
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.
if ttl != 0
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.
nvm. you put this into the opt
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 rename this to s.createOptForTTL to hide the lease concept entirely.
GCE e2e build/test passed for commit 6f79f2c0575ef3c2b2019811a237f398dc8e4ab4. |
Raising Xiang's comment to the top level:
This seems fine to me. My thought is that we need update docs in interface that says "ttl is an approximate number". |
I believe so. Based on the offline discussion with @lavalamp, it seems that TTL is only used for GC for now. So we are free to modify the comment on the interface I guess. |
@hongchaodeng As long as we do not create 100s of leases per second, it should be fine. |
GCE e2e build/test passed for commit 44847012ee017c42015b617fa5d51c2db1337b69. |
@@ -330,10 +330,7 @@ func (e *Etcd) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool | |||
if err != nil { | |||
return nil, nil, err | |||
} | |||
if int64(ttl) != res.TTL { |
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 suggest not making this change?
We might create 100's of events per second under heavy load (big cluster, many pods starting at once). I'm not sure what the sustained rate would be-- probably much less than that? |
@hongchaodeng - please rebase |
GCE e2e build/test passed for commit 6465ce042bc3c9b0eb543fb3f37ec3ab4ec4abba. |
Thanks - will take a look tomorrow. Sorry for delay. |
|
||
// createOpts creates the etcd client options based on given parameters. | ||
// ttl: if ttl is non-zero, it will attach the key to a lease with ttl of roughly equivalent length | ||
func (s *store) createOpts(ctx context.Context, ttl int64) ([]clientv3.OpOption, error) { |
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 actually is just about TTL, not about create. Can you please name it like "ttlOpts" (or "ttlCreateOpts") or sth like that?
Added some comments. But I will wait for the watcher PR to be merge before lgtm-ing this one. |
@wojtek-t Watch pr is merged :) |
Addressed. PTAL. |
GCE e2e build/test passed for commit 3e9405822eb9c84108607f4cdd6dcd291d36b233. |
GCE e2e build/test passed for commit 46214c6. |
LGTM |
GCE e2e build/test passed for commit 46214c6. |
GCE e2e build/test passed for commit 46214c6. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit 46214c6. |
Automatic merge from submit-queue |
ref: #22448
What's included in the PR?
Note