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

client: make handshake required 'on' by default, not 'hybrid' #2565

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ func newFuncDialOption(f func(*dialOptions)) *funcDialOption {
// WithWaitForHandshake blocks until the initial settings frame is received from
// the server before assigning RPCs to the connection.
//
// Deprecated: this will become the default behavior in the 1.18 release, and
// will be removed after the 1.18 release. To override the default behavior in
// the 1.18 release, either use this dial option or set the environment
// variable GRPC_GO_READY_BEFORE_HANDSHAKE=on.
// Deprecated: this is the default behavior, and this option will be removed
// after the 1.18 release.
func WithWaitForHandshake() DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.reqHandshake = envconfig.RequireHandshakeOn
Expand Down
1 change: 1 addition & 0 deletions internal/envconfig/envconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var (
func init() {
switch strings.ToLower(os.Getenv(requireHandshakeStr)) {
case "on":
default:
RequireHandshake = RequireHandshakeOn
case "off":
RequireHandshake = RequireHandshakeOff
Expand Down
2 changes: 0 additions & 2 deletions test/channelz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,6 @@ func (s) TestCZSubChannelConnectivityState(t *testing.T) {
defer cleanup()
r.InitialAddrs([]resolver.Address{{Addr: te.srvAddr}})
te.resolverScheme = r.Scheme()
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
cc := te.clientConn()
defer te.tearDown()
tc := testpb.NewTestServiceClient(cc)
Expand Down Expand Up @@ -1750,7 +1749,6 @@ func (s) TestCZChannelConnectivityState(t *testing.T) {
defer cleanup()
r.InitialAddrs([]resolver.Address{{Addr: te.srvAddr}})
te.resolverScheme = r.Scheme()
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
cc := te.clientConn()
defer te.tearDown()
tc := testpb.NewTestServiceClient(cc)
Expand Down
1 change: 0 additions & 1 deletion test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ func (s) TestTimeoutOnDeadServer(t *testing.T) {

func testTimeoutOnDeadServer(t *testing.T, e env) {
te := newTest(t, e)
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
te.userAgent = testAppUA
te.declareLogNoise(
"transport: http2Client.notifyError got notified that the client transport was broken EOF",
Expand Down
7 changes: 7 additions & 0 deletions test/gracefulstop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"google.golang.org/grpc"

"google.golang.org/grpc/internal/envconfig"
testpb "google.golang.org/grpc/test/grpc_testing"
)

Expand Down Expand Up @@ -106,6 +107,11 @@ func (d *delayConn) Read(b []byte) (n int, err error) {
}

func (s) TestGracefulStop(t *testing.T) {
// Set default behavior and restore current setting after test.
old := envconfig.RequireHandshake
envconfig.RequireHandshake = envconfig.RequireHandshakeOff
defer func() { envconfig.RequireHandshake = old }()

// This test ensures GracefulStop cannot race and break RPCs on new
// connections created after GracefulStop was called but before
// listener.Accept() returns a "closing" error.
Expand Down Expand Up @@ -176,6 +182,7 @@ func (s) TestGracefulStop(t *testing.T) {
defer dialCancel()
cc, err := grpc.DialContext(ctx, "", grpc.WithInsecure(), grpc.WithBlock(), grpc.WithDialer(d))
if err != nil {
dlis.allowClientRead()
t.Fatalf("grpc.Dial(%q) = %v", lis.Addr().String(), err)
}
client := testpb.NewTestServiceClient(cc)
Expand Down
2 changes: 0 additions & 2 deletions test/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ func (s) TestHealthCheckWithConnClose(t *testing.T) {
cc, r, deferFunc, err := setupClient(&clientConfig{
balancerName: "round_robin",
testHealthCheckFuncWrapper: testHealthCheckFuncWrapper,
extraDialOption: []grpc.DialOption{grpc.WithWaitForHandshake()},
})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -689,7 +688,6 @@ func (s) TestHealthCheckWithoutReportHealthCalled(t *testing.T) {
_, r, deferFunc, err := setupClient(&clientConfig{
balancerName: "round_robin",
testHealthCheckFuncWrapper: testHealthCheckFuncWrapper,
extraDialOption: []grpc.DialOption{grpc.WithWaitForHandshake()},
})
if err != nil {
t.Fatal(err)
Expand Down