Pārlūkot izejas kodu

etcd-tester: no error for compact double-send

When compactKV request is halted before final acknowledgement,
it used to just continue on the next endpoint. But there could be
a case than compactKV is requested twice, and the first one is already
replicated and applied by the time the second request was to be
applied (returning compact revision error). This skips the case
by parsing the error message.
Gyu-Ho Lee 10 gadi atpakaļ
vecāks
revīzija
f9b90e13ac
1 mainītis faili ar 7 papildinājumiem un 4 dzēšanām
  1. 7 4
      tools/functional-tester/etcd-tester/cluster.go

+ 7 - 4
tools/functional-tester/etcd-tester/cluster.go

@@ -327,18 +327,21 @@ func (c *cluster) compactKV(rev int64) error {
 		return nil
 		return nil
 	}
 	}
 
 
-	for _, u := range c.GRPCURLs {
+	for i, u := range c.GRPCURLs {
 		conn, err = grpc.Dial(u, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
 		conn, err = grpc.Dial(u, grpc.WithInsecure(), grpc.WithTimeout(5*time.Second))
 		if err != nil {
 		if err != nil {
 			continue
 			continue
 		}
 		}
 		kvc := pb.NewKVClient(conn)
 		kvc := pb.NewKVClient(conn)
-		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 		_, err = kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true})
 		_, err = kvc.Compact(ctx, &pb.CompactionRequest{Revision: rev, Physical: true})
 		cancel()
 		cancel()
 		conn.Close()
 		conn.Close()
-		if err == nil {
-			return nil
+		if err != nil {
+			if strings.Contains(err.Error(), "required revision has been compacted") && i > 0 {
+				plog.Printf("%s is already compacted with %d (%v)", u, rev, err)
+				err = nil // in case compact was requested more than once
+			}
 		}
 		}
 	}
 	}
 	return err
 	return err