mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #9052 from gyuho/lease-timetolive-output
etcdctl/ctlv3: clarify "lease timetolive" output on expired lease
This commit is contained in:
commit
e378b9831c
@ -94,12 +94,8 @@ func leaseTestTimeToLiveExpire(cx ctlCtx, ttl int) error {
|
||||
// eliminate false positive
|
||||
time.Sleep(time.Duration(ttl+1) * time.Second)
|
||||
cmdArgs := append(cx.PrefixArgs(), "lease", "timetolive", leaseID)
|
||||
proc, err := spawnCmd(cmdArgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = proc.Expect("TTL(0s), remaining(-1s)") // expect expired lease
|
||||
if err != nil {
|
||||
exp := fmt.Sprintf("lease %s already expired", leaseID)
|
||||
if err = spawnWithExpect(cmdArgs, exp); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ctlV3Get(cx, []string{"key"}); err != nil {
|
||||
|
@ -468,6 +468,9 @@ Prints lease information.
|
||||
|
||||
./etcdctl lease timetolive 2d8257079fa1bc0c --write-out=json --keys
|
||||
# {"cluster_id":17186838941855831277,"member_id":4845372305070271874,"revision":3,"raft_term":2,"id":3279279168933706764,"ttl":459,"granted-ttl":500,"keys":["Zm9vMQ==","Zm9vMg=="]}
|
||||
|
||||
./etcdctl lease timetolive 2d8257079fa1bc0c
|
||||
# lease 2d8257079fa1bc0c already expired
|
||||
```
|
||||
|
||||
### LEASE LIST
|
||||
|
@ -93,6 +93,11 @@ func (p *simplePrinter) KeepAlive(resp v3.LeaseKeepAliveResponse) {
|
||||
}
|
||||
|
||||
func (s *simplePrinter) TimeToLive(resp v3.LeaseTimeToLiveResponse, keys bool) {
|
||||
if resp.GrantedTTL == 0 && resp.TTL == -1 {
|
||||
fmt.Printf("lease %016x already expired\n", resp.ID)
|
||||
return
|
||||
}
|
||||
|
||||
txt := fmt.Sprintf("lease %016x granted with TTL(%ds), remaining(%ds)", resp.ID, resp.GrantedTTL, resp.TTL)
|
||||
if keys {
|
||||
ks := make([]string, len(resp.Keys))
|
||||
|
Loading…
x
Reference in New Issue
Block a user