Merge pull request #5089 from heyitsanthony/fix-func-tester-timeout
etcd-tester: return error if first compaction times outrelease-3.0
commit
6c1cc1d4ea
|
@ -320,30 +320,27 @@ func (c *cluster) getRevisionHash() (map[string]int64, map[string]int64, error)
|
||||||
return revs, hashes, nil
|
return revs, hashes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) compactKV(rev int64) error {
|
func (c *cluster) compactKV(rev int64) (err error) {
|
||||||
var (
|
|
||||||
conn *grpc.ClientConn
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
if rev <= 0 {
|
if rev <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, u := range c.GRPCURLs {
|
for i, u := range c.GRPCURLs {
|
||||||
conn, err = grpc.Dial(u, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
|
conn, derr := grpc.Dial(u, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
|
||||||
if err != nil {
|
if derr != nil {
|
||||||
|
err = derr
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
kvc := pb.NewKVClient(conn)
|
kvc := pb.NewKVClient(conn)
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
_, err = kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true})
|
_, cerr := kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true})
|
||||||
cancel()
|
cancel()
|
||||||
conn.Close()
|
conn.Close()
|
||||||
if err != nil {
|
if cerr != nil {
|
||||||
if strings.Contains(err.Error(), "required revision has been compacted") && i > 0 {
|
if strings.Contains(err.Error(), "required revision has been compacted") && i > 0 {
|
||||||
plog.Printf("%s is already compacted with %d (%v)", u, rev, err)
|
plog.Printf("%s is already compacted with %d (%v)", u, rev, cerr)
|
||||||
err = nil // in case compact was requested more than once
|
} else {
|
||||||
|
err = cerr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue