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

cli/quit: clean up some now-unneeded code #49366

Merged
merged 1 commit into from
May 26, 2020
Merged
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
26 changes: 1 addition & 25 deletions pkg/cli/quit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"fmt"
"io"
"strings"
"time"

"github.com/cockroachdb/cockroach/pkg/roachpb"
Expand All @@ -25,8 +24,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/errors"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

// quitCmd command shuts down the node server.
Expand Down Expand Up @@ -227,7 +224,7 @@ func doShutdown(ctx context.Context, c serverpb.AdminClient) (hardError bool, er
err = errors.WithHint(err, "You can still stop the process using a service manager or a signal.")
hardError = true
}
if grpcutil.IsClosedConnection(err) || grpcConfusedErrConnClosedByPeer(err) {
if grpcutil.IsClosedConnection(err) {
// This most likely means that we shut down successfully. Note
// that sometimes the connection can be shut down even before a
// DrainResponse gets sent back to us, so we don't require a
Expand Down Expand Up @@ -270,24 +267,3 @@ func getAdminClient(ctx context.Context, cfg server.Config) (serverpb.AdminClien
}
return serverpb.NewAdminClient(conn), finish, nil
}

// grpcConfusedErrConnClosedByPeer returns true if the given error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this were still needed, how would we find out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestDockerCLI will start to flake again.

// has been likely produced by a gRPC handshake that was confused
// by the remote end closing the connection.
// This situation occurs semi-frequently (10-15% of cases) in
// go 1.13, and may have been eliminated in 1.14.
func grpcConfusedErrConnClosedByPeer(err error) bool {
err = errors.Cause(err)
s, ok := status.FromError(err)
if !ok {
return false
}
switch {
case s.Code() == codes.Internal && strings.Contains(err.Error(), "compressed flag set with identity or empty encoding"):
return true
case s.Code() == codes.Unimplemented && strings.Contains(err.Error(), "Decompressor is not installed"):
return true
default:
return false
}
}