siso: partial revert: use grpc.NewClient
WithBlock behavior doesn't work with grpc.NewClient?
https://ci.chromium.org/ui/p/chromium/builders/build/win-build-perf-developer/1232/overview
```
> INFO 2024-06-20T23:48:19.820383800Z prepare-local-inputs 2478 2.7671ms: <nil>
> INFO 2024-06-20T23:48:19.883818900Z step state: remote exec (via reproxy)
> WARNING 2024-06-20T23:48:19.886018800Z dial pipe://reproxy.pipe connectivity=TRANSIENT_FAILURE
> WARNING 2024-06-21T00:18:19.889120200Z dial pipe://reproxy.pipe connectivity=TRANSIENT_FAILURE
> WARNING 2024-06-21T00:48:19.906759500Z dial pipe://reproxy.pipe connectivity=TRANSIENT_FAILURE
> INFO 2024-06-21T01:17:51.175555100Z cached=false
> INFO 2024-06-21T01:17:51.175555100Z done err=reproxy error: failed to dial pipe://reproxy.pipe: interrupt by signal
```
so, use grpc.DialContext for reproxy.
Change-Id: I96d08970f91f029ee0fad671e301943b3184ec84
Reviewed-on: https://chromium-review.googlesource.com/c/infra/infra/+/5644573
Reviewed-by: Junji Watanabe <jwata@google.com>
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
Cr-Commit-Position: refs/heads/main@{#66336}
diff --git a/go/src/infra/build/siso/execute/reproxyexec/dial_unix.go b/go/src/infra/build/siso/execute/reproxyexec/dial_unix.go
index 36c76af..0e23f6c 100644
--- a/go/src/infra/build/siso/execute/reproxyexec/dial_unix.go
+++ b/go/src/infra/build/siso/execute/reproxyexec/dial_unix.go
@@ -13,10 +13,17 @@
"google.golang.org/grpc/credentials/insecure"
)
-// dialContext connects to the serverAddress for grpc.
-func dialContext(ctx context.Context, serverAddr string) (*grpc.ClientConn, error) {
- return grpc.NewClient(
+// DialContext connects to the serverAddress for grpc.
+func DialContext(ctx context.Context, serverAddr string) (*grpc.ClientConn, error) {
+ // Although grpc.DialContxt is deprecated, but grpc.NewClient
+ // doesn't have blocking feature.
+ // https://crrev.com/c/5642324 didn't work well?
+ // https://ci.chromium.org/ui/p/chromium/builders/build/win-build-perf-developer/1232/overview
+ return grpc.DialContext(
+ ctx,
serverAddr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
+ // Ensure blocking due to flaky reproxy behavior http://tg/639661.
+ grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(grpcMaxMsgSize)))
}
diff --git a/go/src/infra/build/siso/execute/reproxyexec/dial_windows.go b/go/src/infra/build/siso/execute/reproxyexec/dial_windows.go
index 8ec0b24..cde74cb 100644
--- a/go/src/infra/build/siso/execute/reproxyexec/dial_windows.go
+++ b/go/src/infra/build/siso/execute/reproxyexec/dial_windows.go
@@ -15,23 +15,33 @@
"google.golang.org/grpc"
)
-// dialContext connects to the serverAddress for grpc.
+// DialContext connects to the serverAddress for grpc.
// if serverAddr is `pipe://<addr>`, it connects to named pipe (`\\.\\pipe\<addr>`).
-func dialContext(ctx context.Context, serverAddr string) (*grpc.ClientConn, error) {
+func DialContext(ctx context.Context, serverAddr string) (*grpc.ClientConn, error) {
if strings.HasPrefix(serverAddr, "pipe://") {
return dialPipe(ctx, strings.TrimPrefix(serverAddr, "pipe://"))
}
- return grpc.NewClient(
+ // Although grpc.DialContxt is deprecated, but grpc.NewClient
+ // doesn't have blocking feature.
+ // https://crrev.com/c/5642324 didn't work well?
+ // https://ci.chromium.org/ui/p/chromium/builders/build/win-build-perf-developer/1232/overview
+ return grpc.DialContext(
+ ctx,
serverAddr,
grpc.WithInsecure(),
+ // Ensure blocking due to flaky reproxy behavior http://tg/639661.
+ grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(grpcMaxMsgSize)))
}
func dialPipe(ctx context.Context, pipe string) (*grpc.ClientConn, error) {
addr := `\\.\pipe\` + pipe
- return grpc.NewClient(
+ return grpc.DialContext(
+ ctx,
addr,
grpc.WithInsecure(),
+ // Ensure blocking due to flaky reproxy behavior http://tg/639661.
+ grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(grpcMaxMsgSize)),
grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return winio.DialPipeContext(ctx, addr)
diff --git a/go/src/infra/build/siso/execute/reproxyexec/reproxyexec.go b/go/src/infra/build/siso/execute/reproxyexec/reproxyexec.go
index 5ee865d..aff8990 100644
--- a/go/src/infra/build/siso/execute/reproxyexec/reproxyexec.go
+++ b/go/src/infra/build/siso/execute/reproxyexec/reproxyexec.go
@@ -24,7 +24,6 @@
rpb "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
- "google.golang.org/grpc/connectivity"
"google.golang.org/grpc/status"
"infra/build/siso/execute"
@@ -156,28 +155,11 @@
re.connOnce.Do(func() {
ctx, cancel := context.WithTimeout(ctx, dialTimeout)
defer cancel()
- re.conn, re.connErr = dialContext(ctx, re.connAddress)
+ re.conn, re.connErr = DialContext(ctx, re.connAddress)
})
if re.connErr != nil {
return fmt.Errorf("fail to dial %s: %w", re.connAddress, re.connErr)
}
- // Ensure blocking due to flaky reproxy behavior http://tg/639661.
-blockConn:
- for {
- s := re.conn.GetState()
- switch s {
- case connectivity.Idle:
- re.conn.Connect()
- case connectivity.Ready:
- break blockConn
- default:
- clog.Warningf(ctx, "dial %s connectivity=%s", re.connAddress, s)
- }
- for !re.conn.WaitForStateChange(ctx, s) {
- // context got timeout or canceled.
- return fmt.Errorf("failed to dial %s: %w", re.connAddress, context.Cause(ctx))
- }
- }
// Create REProxy client and send the request with backoff configuration above.
// (No timeout applied due to use of backoff with maximum attempts allowed.)