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

fix(bulk): fixing bulk loader when encryption + mtls is enabled #7154

Merged
merged 3 commits into from
Dec 16, 2020
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
13 changes: 0 additions & 13 deletions dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/worker"
"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
Expand Down Expand Up @@ -126,18 +125,6 @@ func (r *reducer) run() error {
}

func (r *reducer) createBadgerInternal(dir string, compression bool) *badger.DB {
if r.opt.EncryptionKey != nil {
// Need to set zero addr in WorkerConfig before checking the license.
x.WorkerConfig.ZeroAddr = []string{r.opt.ZeroAddr}

if !worker.EnterpriseEnabled() {
// Crash since the enterprise license is not enabled..
log.Fatal("Enterprise License needed for the Encryption feature.")
} else {
log.Printf("Encryption feature enabled.")
}
}

key := r.opt.EncryptionKey
if !r.opt.EncryptedOut {
key = nil
Expand Down
14 changes: 14 additions & 0 deletions dgraph/cmd/bulk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"strconv"
"strings"

"github.com/dgraph-io/dgraph/worker"

"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/tok"
"github.com/dgraph-io/dgraph/x"
Expand Down Expand Up @@ -187,6 +189,18 @@ func run() {
fmt.Fprint(os.Stderr, "Must set --encrypted and/or --encrypted_out to true when providing encryption key.\n")
os.Exit(1)
}

tlsConf, err := x.LoadClientTLSConfigForInternalPort(Bulk.Conf)
x.Check(err)
// Need to set zero addr in WorkerConfig before checking the license.
x.WorkerConfig.ZeroAddr = []string{opt.ZeroAddr}
x.WorkerConfig.TLSClientConfig = tlsConf
if !worker.EnterpriseEnabled() {
// Crash since the enterprise license is not enabled..
log.Fatal("Enterprise License needed for the Encryption feature.")
} else {
log.Printf("Encryption feature enabled.")
}
}
fmt.Printf("Encrypted input: %v; Encrypted output: %v\n", opt.Encrypted, opt.EncryptedOut)

Expand Down