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

*: lease timetolive #6321

Merged
merged 8 commits into from
Sep 8, 2016
Merged

*: lease timetolive #6321

merged 8 commits into from
Sep 8, 2016

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Aug 31, 2016

Fix #5868.

int64 ID = 1;
}

message LeaseLookupResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we should also response with all the keys that attached to the lease?

@gyuho gyuho added WIP labels Aug 31, 2016
@gyuho gyuho changed the title *: support lease information retrieve in client side *: lease probing via keep-alive path Sep 1, 2016
@gyuho gyuho force-pushed the lease-information branch from 52bf04d to f20039f Compare September 1, 2016 08:31
@gyuho gyuho removed the WIP label Sep 1, 2016
@gyuho gyuho force-pushed the lease-information branch 6 times, most recently from e33eb9f to 95e7079 Compare September 1, 2016 08:55
@@ -648,6 +648,8 @@ message LeaseRevokeResponse {
message LeaseKeepAliveRequest {
// ID is the lease ID for the lease to keep alive.
int64 ID = 1;
// Probe is true, then it only retrieves lease information without renewing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Retrieve lease information without refreshing the lease.?

for i := range resp.Keys {
ks[i] = string(resp.Keys[i])
}
fmt.Printf("lease %016x granted with TTL(%ds), remaining(%ds), keys(%v)\n", resp.ID, resp.GrantedTTL, resp.TTL, ks)
Copy link
Contributor

Choose a reason for hiding this comment

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

keys -> attached keys

@xiang90
Copy link
Contributor

xiang90 commented Sep 7, 2016

Thanks @gyuho!

LGTM. Defer to @heyitsanthony

@gyuho gyuho force-pushed the lease-information branch from a77df00 to 53351e2 Compare September 7, 2016 08:18
// GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
int64 grantedTTL = 4;
// Keys is the list of keys attached to this lease.
repeated string keys = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

this has to be repeated bytes since "A string must always contain UTF-8 encoded or 7-bit ASCII text." but etcd keys can be arbitrary binary strings

@gyuho gyuho force-pushed the lease-information branch from 53351e2 to 2647034 Compare September 8, 2016 02:32
@gyuho
Copy link
Contributor Author

gyuho commented Sep 8, 2016

@heyitsanthony All addressed. PTAL.

  1. changed Keys to [][]byte
  2. changed TTL to float64 to not truncate milliseconds
  3. changed output function to print out attached keys only when --keys flag is passed
  4. added LeaseOption to clientv3
  5. fixed toErr

Thanks!

@@ -60,6 +60,7 @@ for dir in ${DIRS}; do
protoc --gofast_out=plugins=grpc,import_prefix=github.com/coreos/:. -I=.:"${GOGOPROTO_PATH}":"${COREOS_ROOT}":"${GRPC_GATEWAY_ROOT}/third_party/googleapis" *.proto
sed -i.bak -E "s/github\.com\/coreos\/(gogoproto|github\.com|golang\.org|google\.golang\.org)/\1/g" *.pb.go
sed -i.bak -E 's/github\.com\/coreos\/(errors|fmt|io)/\1/g' *.pb.go
sed -i.bak -E 's/import math \"github\.com\/coreos\/math\"//g' *.pb.go
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed when proto file has double field, the generated Go code inserts import math "github.com/coreos/math" line.

@gyuho gyuho force-pushed the lease-information branch from 2647034 to d444668 Compare September 8, 2016 07:27
@gyuho
Copy link
Contributor Author

gyuho commented Sep 8, 2016

Now TTL is int64

ID LeaseID `json:"id"`

// TTL is the remaining TTL in seconds for the lease.
// Milliseconds will be rounded off.
Copy link
Contributor

Choose a reason for hiding this comment

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

TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.?

@heyitsanthony
Copy link
Contributor

lgtm after fixing minor doc nit. Thanks!

@gyuho gyuho force-pushed the lease-information branch from d444668 to b7dc6cc Compare September 8, 2016 23:22
@gyuho
Copy link
Contributor Author

gyuho commented Sep 8, 2016

Just updated the comments. Will merge after greens. Thanks a lot!

@gyuho gyuho merged commit 0b67584 into etcd-io:master Sep 8, 2016
@gyuho gyuho deleted the lease-information branch September 8, 2016 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants