Skip to content

Commit 377f63b

Browse files
committed
chore(core): remove slash grpc handling
1 parent 1d4b617 commit 377f63b

4 files changed

Lines changed: 7 additions & 61 deletions

File tree

dgraph/cmd/live/run.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
"github.com/golang/glog"
2626
"github.com/pkg/errors"
2727
"github.com/spf13/cobra"
28-
"github.com/spf13/viper"
29-
"google.golang.org/grpc"
3028
"google.golang.org/grpc/metadata"
3129

3230
"github.com/dgraph-io/badger/v4"
@@ -142,12 +140,7 @@ func init() {
142140
"Number of N-Quads to send as part of a mutation.")
143141
flag.StringP("xidmap", "x", "", "Directory to store xid to uid mapping")
144142
flag.StringP("auth_token", "t", "",
145-
"The auth token passed to the server for Alter operation of the schema file. "+
146-
"If used with --slash_grpc_endpoint, then this should be set to the API token issued"+
147-
"by Slash GraphQL")
148-
flag.String("slash_grpc_endpoint", "", "Path to Slash GraphQL GRPC endpoint. "+
149-
"If --slash_grpc_endpoint is set, all other TLS options and connection options will be"+
150-
"ignored")
143+
"The auth token passed to the server for Alter operation of the schema file")
151144
flag.BoolP("use_compression", "C", false,
152145
"Enable compression on connection to alpha server")
153146
flag.Bool("new_uids", false,
@@ -584,7 +577,7 @@ func (l *loader) processLoadFile(ctx context.Context, rd *bufio.Reader, ck chunk
584577
return <-errCh
585578
}
586579

587-
func setup(opts batchMutationOptions, dc *dgo.Dgraph, conf *viper.Viper) *loader {
580+
func setup(opts batchMutationOptions, dc *dgo.Dgraph) *loader {
588581
var db *badger.DB
589582
if len(opt.clientDir) > 0 {
590583
x.Check(os.MkdirAll(opt.clientDir, 0700))
@@ -599,11 +592,6 @@ func setup(opts batchMutationOptions, dc *dgo.Dgraph, conf *viper.Viper) *loader
599592
x.Checkf(err, "Error while creating badger KV posting store")
600593
}
601594

602-
dialOpts := []grpc.DialOption{}
603-
if conf.GetString("slash_grpc_endpoint") != "" && conf.IsSet("auth_token") {
604-
dialOpts = append(dialOpts, x.WithAuthorizationCredentials(conf.GetString("auth_token")))
605-
}
606-
607595
xopts := xidmap.XidMapOptions{DB: db, DgClient: dc}
608596
alloc := xidmap.New(xopts)
609597
l := &loader{
@@ -745,7 +733,7 @@ func run() error {
745733
dg, closeFunc := x.GetDgraphClient(Live.Conf, true)
746734
defer closeFunc()
747735

748-
l := setup(bmOpts, dg, Live.Conf)
736+
l := setup(bmOpts, dg)
749737
if err := l.populateNamespaces(ctx, dg, singleNsOp); err != nil {
750738
fmt.Printf("Error while populating namespaces %s\n", err)
751739
return err

upgrade/upgrade.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type versionComparisonResult uint8
3333
const (
3434
dryRun = "dry-run"
3535
alpha = "alpha"
36-
slashGrpc = "slash_grpc_endpoint"
3736
authToken = "auth_token"
3837
alphaHttp = "alpha-http"
3938
user = "user"
@@ -146,13 +145,8 @@ func init() {
146145
flag.Bool(dryRun, false, "dry-run the upgrade")
147146
flag.StringP(alpha, "a", "127.0.0.1:9080",
148147
"Comma separated list of Dgraph Alpha gRPC server address")
149-
flag.String(slashGrpc, "", "Path to Slash GraphQL GRPC endpoint. "+
150-
"If --slash_grpc_endpoint is set, all other TLS options and connection options will be "+
151-
"ignored")
152148
flag.String(authToken, "",
153-
"The auth token passed to the server for Alter operation of the schema file. "+
154-
"If used with --slash_grpc_endpoint, then this should be set to the API token issued"+
155-
"by Slash GraphQL")
149+
"The auth token passed to the server for Alter operation of the schema file")
156150
flag.String(alphaHttp, "http://127.0.0.1:8080", "Draph Alpha HTTP(S) endpoint.")
157151
flag.StringP(user, "u", "", "Username of ACL user")
158152
flag.StringP(password, "p", "", "Password of ACL user")

x/tls_helper.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,31 +147,12 @@ func LoadServerTLSConfig(v *viper.Viper) (*tls.Config, error) {
147147
return GenerateServerTLSConfig(&conf)
148148
}
149149

150-
// SlashTLSConfig returns the TLS config appropriate for SlashGraphQL
151-
// This assumes that endpoint is not empty, and in the format "domain.grpc.cloud.dg.io:443"
152-
func SlashTLSConfig(endpoint string) (*tls.Config, error) {
153-
pool, err := generateCertPool("", true)
154-
if err != nil {
155-
return nil, err
156-
}
157-
hostWithoutPort := strings.Split(endpoint, ":")[0]
158-
return &tls.Config{
159-
RootCAs: pool,
160-
ServerName: hostWithoutPort,
161-
MinVersion: tls.VersionTLS12,
162-
}, nil
163-
}
164-
165150
// LoadClientTLSConfig loads the TLS config into the client with the given parameters.
166151
func LoadClientTLSConfig(v *viper.Viper) (*tls.Config, error) {
167-
if v.GetString("slash_grpc_endpoint") != "" {
168-
return SlashTLSConfig(v.GetString("slash_grpc_endpoint"))
169-
}
170-
171152
tlsFlag := z.NewSuperFlag(v.GetString("tls")).MergeAndCheckDefault(TLSDefaults)
172153

173154
// When the --tls ca-cert="..."; option is specified, the connection will be set up using TLS
174-
// instead of plaintext. However the client cert files are optional, depending on whether the
155+
// instead of plaintext. However, the client cert files are optional, depending on whether the
175156
// server requires a client certificate.
176157
caCert := tlsFlag.GetPath("ca-cert")
177158
if caCert != "" {

x/x.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,25 +1034,13 @@ func (a *authorizationCredentials) RequireTransportSecurity() bool {
10341034
return true
10351035
}
10361036

1037-
// WithAuthorizationCredentials adds Authorization: <api-token> to every GRPC request
1038-
// This is mostly used by Slash GraphQL to authenticate requests
1039-
func WithAuthorizationCredentials(authToken string) grpc.DialOption {
1040-
return grpc.WithPerRPCCredentials(&authorizationCredentials{authToken})
1041-
}
1042-
10431037
// GetDgraphClient creates a Dgraph client based on the following options in the configuration:
1044-
// --slash_grpc_endpoint specifies the grpc endpoint for slash. It takes precedence over --alpha and TLS
10451038
// --alpha specifies a comma separated list of endpoints to connect to
10461039
// --tls "ca-cert=; client-cert=; client-key=;" etc specify the TLS configuration of the connection
10471040
// --retries specifies how many times we should retry the connection to each endpoint upon failures
10481041
// --user and --password specify the credentials we should use to login with the server
10491042
func GetDgraphClient(conf *viper.Viper, login bool) (*dgo.Dgraph, CloseFunc) {
1050-
var alphas string
1051-
if conf.GetString("slash_grpc_endpoint") != "" {
1052-
alphas = conf.GetString("slash_grpc_endpoint")
1053-
} else {
1054-
alphas = conf.GetString("alpha")
1055-
}
1043+
var alphas = conf.GetString("alpha")
10561044

10571045
if len(alphas) == 0 {
10581046
glog.Fatalf("The --alpha option must be set in order to connect to Dgraph")
@@ -1074,15 +1062,10 @@ func GetDgraphClient(conf *viper.Viper, login bool) (*dgo.Dgraph, CloseFunc) {
10741062
}
10751063
}
10761064

1077-
dialOpts := []grpc.DialOption{}
1078-
if conf.GetString("slash_grpc_endpoint") != "" && conf.IsSet("auth_token") {
1079-
dialOpts = append(dialOpts, WithAuthorizationCredentials(conf.GetString("auth_token")))
1080-
}
1081-
10821065
for _, d := range ds {
10831066
var conn *grpc.ClientConn
10841067
for range retries {
1085-
conn, err = SetupConnection(d, tlsCfg, false, dialOpts...)
1068+
conn, err = SetupConnection(d, tlsCfg, false)
10861069
if err == nil {
10871070
break
10881071
}

0 commit comments

Comments
 (0)