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

build: Fix OSS build #9172

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

build: Fix OSS build #9172

wants to merge 1 commit into from

Conversation

RJKeevil
Copy link
Contributor

@RJKeevil RJKeevil commented Sep 14, 2024

Perhaps my misunderstanding, but running "make install_oss" fails on the main repo, as e.g. on line 665 of dgraph/cmd/alpha/run.go calls ee.GetKeys, which will always return an error in OSS mode. This change returns an empty struct instead of an error, allowing the build to complete.

@RJKeevil RJKeevil requested a review from a team as a code owner September 14, 2024 14:35
@RJKeevil
Copy link
Contributor Author

Perhaps this change is not needed as OSS build was already in your tests, but now i'm confused how alpha/run.go could ever pass compilation without this?

@mangalaman93
Copy link
Contributor

Perhaps this change is not needed as OSS build was already in your tests, but now i'm confused how alpha/run.go could ever pass compilation without this?

We do not support Encryption in OSS mode.

@RJKeevil
Copy link
Contributor Author

RJKeevil commented Sep 15, 2024

@mangalaman93 yes totally understand, I'm not trying to add EE feature to OSS, and I don't want encryption. For me the default oss-install compilation failed as it tries to enable encryption on that line, i'm trying to make sure it doesnt!

@mangalaman93
Copy link
Contributor

make oss works for me. Could you show me the issue you are facing?

@RJKeevil
Copy link
Contributor Author

RJKeevil commented Sep 16, 2024

@mangalaman93 Correction, the make step indeed passes, but then launching an OSS dgraph alpha node gives the following without this change:
Executing dgraph with arguments: alpha --my=alpha1:7080 --zero=zero1:5080 --security whitelist=0.0.0.0/0 --limit mutations=strict --badger numgoroutines=12 --cache size-mb=5120; percentage=0,80,20; --trace ratio=0.0000001 --telemetry sentry=false; reports=false; --tls
2024-09-16 12:10:39 dgraph running with user: alchemiauser, id: 1000
2024-09-16 12:10:39 2024/09/16 10:10:39 flags: acl / encryption is an enterprise-only feature
2024-09-16 12:10:39
2024-09-16 12:10:39 github.com/dgraph-io/dgraph/v24/x.Check
2024-09-16 12:10:39 /dgraph/x/error.go:42
2024-09-16 12:10:39 github.com/dgraph-io/dgraph/v24/dgraph/cmd/alpha.run
2024-09-16 12:10:39 /dgraph/dgraph/cmd/alpha/run.go:666
2024-09-16 12:10:39 github.com/dgraph-io/dgraph/v24/dgraph/cmd/alpha.init.0.func1
2024-09-16 12:10:39 /dgraph/dgraph/cmd/alpha/run.go:92
2024-09-16 12:10:39 github.com/spf13/cobra.(*Command).execute
2024-09-16 12:10:39 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:989
2024-09-16 12:10:39 github.com/spf13/cobra.(*Command).ExecuteC
2024-09-16 12:10:39 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
2024-09-16 12:10:39 github.com/spf13/cobra.(*Command).Execute
2024-09-16 12:10:39 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
2024-09-16 12:10:39 github.com/dgraph-io/dgraph/v24/dgraph/cmd.Execute
2024-09-16 12:10:39 /dgraph/dgraph/cmd/root.go:79
2024-09-16 12:10:39 main.main
2024-09-16 12:10:39 /dgraph/dgraph/main.go:98
2024-09-16 12:10:39 runtime.main
2024-09-16 12:10:39 /usr/local/go/src/runtime/proc.go:272
2024-09-16 12:10:39 runtime.goexit
2024-09-16 12:10:39 /usr/local/go/src/runtime/asm_amd64.s:1700
2024-09-16 12:10:40 2024/09/16 10:10:40 flags: acl / encryption is an enterprise-only feature
2024-09-16 12:10:40
2024-09-16 12:10:40 github.com/dgraph-io/dgraph/v24/x.Check
2024-09-16 12:10:40 /dgraph/x/error.go:42
2024-09-16 12:10:40 github.com/dgraph-io/dgraph/v24/dgraph/cmd/alpha.run
2024-09-16 12:10:40 /dgraph/dgraph/cmd/alpha/run.go:666
2024-09-16 12:10:40 github.com/dgraph-io/dgraph/v24/dgraph/cmd/alpha.init.0.func1
2024-09-16 12:10:40 /dgraph/dgraph/cmd/alpha/run.go:92
2024-09-16 12:10:40 github.com/spf13/cobra.(*Command).execute
2024-09-16 12:10:40 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:989
2024-09-16 12:10:40 github.com/spf13/cobra.(*Command).ExecuteC
2024-09-16 12:10:40 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
2024-09-16 12:10:40 github.com/spf13/cobra.(*Command).Execute
2024-09-16 12:10:40 /usr/local/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
2024-09-16 12:10:40 github.com/dgraph-io/dgraph/v24/dgraph/cmd.Execute
2024-09-16 12:10:40 /dgraph/dgraph/cmd/root.go:79
2024-09-16 12:10:40 main.main
2024-09-16 12:10:40 /dgraph/dgraph/main.go:98
2024-09-16 12:10:40 runtime.main
2024-09-16 12:10:40 /usr/local/go/src/runtime/proc.go:272
2024-09-16 12:10:40 runtime.goexit
2024-09-16 12:10:40 /usr/local/go/src/runtime/asm_amd64.s:1700
2024-09-16 12:10:40 2024/09/16 10:10:40 flags: acl / encryption is an enterprise-only feature

So the build is fine, but run.go does not appear to have an OSS "mode" as far as I can see, and dies trying to fetch non-defined encryption keys. Maybe I am missing a runtime flag to tell draph to run without encryption, but again I cant see a way that this code could ever work as it is hard-coded to return an error.

@mangalaman93
Copy link
Contributor

What is the command you are using to run zero?

@RJKeevil
Copy link
Contributor Author

RJKeevil commented Sep 16, 2024

For this test Im using:
dgraph zero --my=zero1:5080 --replicas=1 --trace ratio=0.0000001 --telemetry "sentry=false; reports=false;"

@mangalaman93
Copy link
Contributor

@RJKeevil I can reproduce it now. This is the right fix for it. If you could include it along with a test so that it doesn't happen again, that would be acceptable. Thank you for filing this PR.

diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go
index ec0d8d672..51ed3e347 100644
--- a/dgraph/cmd/alpha/run.go
+++ b/dgraph/cmd/alpha/run.go
@@ -663,9 +663,11 @@ func run() {
        }
 
        keys, err := ee.GetKeys(Alpha.Conf)
-       x.Check(err)
+       if err != nil && !strings.Contains(err.Error(), "enterprise") {
+               x.Check(err)
+       }
 
-       if keys.AclSecretKey != nil {
+       if keys != nil && keys.AclSecretKey != nil {
                opts.AclJwtAlg = keys.AclJwtAlg
                opts.AclSecretKey = keys.AclSecretKey
                opts.AclSecretKeyBytes = keys.AclSecretKeyBytes
@@ -705,17 +707,20 @@ func run() {
                Raft:                raft,
                WhiteListedIPRanges: ips,
                StrictMutations:     opts.MutationsMode == worker.StrictMutations,
-               AclEnabled:          keys.AclSecretKey != nil,
                AbortOlderThan:      abortDur,
                StartTime:           startTime,
                Security:            security,
                TLSClientConfig:     tlsClientConf,
                TLSServerConfig:     tlsServerConf,
-               AclJwtAlg:           keys.AclJwtAlg,
-               AclPublicKey:        keys.AclPublicKey,
                Audit:               opts.Audit != nil,
                Badger:              bopts,
        }
+       if keys != nil {
+               x.WorkerConfig.AclEnabled = keys.AclSecretKey != nil
+               x.WorkerConfig.AclJwtAlg = keys.AclJwtAlg
+               x.WorkerConfig.AclPublicKey = keys.AclPublicKey
+               x.WorkerConfig.EncryptionKey = keys.EncKey
+       }
        x.WorkerConfig.Parse(Alpha.Conf)
 
        if telemetry.GetBool("reports") {
@@ -725,8 +730,6 @@ func run() {
        // Set the directory for temporary buffers.
        z.SetTmpDir(x.WorkerConfig.TmpDir)
 
-       x.WorkerConfig.EncryptionKey = keys.EncKey
-
        setupCustomTokenizers()
        x.Config.PortOffset = Alpha.Conf.GetInt("port_offset")
        x.Config.LimitMutationsNquad = int(x.Config.Limit.GetInt64("mutations-nquad"))

@RJKeevil
Copy link
Contributor Author

Hi @mangalaman93, ee.GetKeys gets called in 9 different places (bulk loader, live loader etc etc) so i chose so solve it in get keys instead. Before i make the change, are you sure you prefer the fix on read of this?

@mangalaman93
Copy link
Contributor

@RJKeevil good point. Feel free to make changes that pass the test and add new tests for oss. I can review the PR once ready. Thanks

@RJKeevil
Copy link
Contributor Author

RJKeevil commented Sep 24, 2024

@mangalaman93 im unclear on what to do with the tests, it looks like in oss mode it runs some unit tests but never e.g. actually starts an alpha. Do I e.g. add the ldbc tests to the oss script? Also note the failing load test above is nothing to do with this change, looks like some random instability unfortunately.

@mangalaman93
Copy link
Contributor

@RJKeevil you are right. We need to add tests for oss build and if you can help us with that, it would be pretty helpful. Happy to merge the PR once we have at least one test. You could pick one from the existing test and figure out a way to run it for oss build. I am busy with a few other things, but I could come back to it in some time if you can't figure it out.

@mangalaman93 mangalaman93 marked this pull request as draft October 15, 2024 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants