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

Add option to apply enterprise license at zero's startup. #5170

Merged
merged 6 commits into from
Apr 14, 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
4 changes: 4 additions & 0 deletions dgraph/cmd/zero/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ func (n *node) updateEnterpriseState(closer *y.Closer) {
func (st *state) applyEnterpriseLicense(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}

func (st *state) applyLicenseFile(path string) error {
return nil
}
12 changes: 12 additions & 0 deletions dgraph/cmd/zero/license_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,15 @@ func (st *state) applyEnterpriseLicense(w http.ResponseWriter, r *http.Request)
}
x.SetStatus(w, x.Success, "Done")
}

// applyLicenseFile applies the license file stored at the given path.
func (st *state) applyLicenseFile(path string) error {
content, err := ioutil.ReadFile(path)
if err != nil {
return err
}

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
return st.zero.applyLicense(ctx, bytes.NewReader(content))
}
8 changes: 8 additions & 0 deletions dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ instances to achieve high-availability.
flag.String("datadog.collector", "", "Send opencensus traces to Datadog. As of now, the trace"+
" exporter does not support annotation logs and would discard them.")
flag.Bool("ludicrous_mode", false, "Run zero in ludicrous mode")
flag.String("enterprise_license", "", "Path to the enterprise license file.")
}

func setupListener(addr string, port int, kind string) (listener net.Listener, err error) {
Expand Down Expand Up @@ -240,6 +241,13 @@ func run() {
st.serveGRPC(grpcListener, store)
st.serveHTTP(httpListener)

// Apply enterprise license if one was given.
if license := Zero.Conf.GetString("enterprise_license"); len(license) > 0 {
if err := st.applyLicenseFile(license); err != nil {
glog.Warningf("Cannot apply enterprise license file %s", license)
}
}

http.HandleFunc("/health", st.pingResponse)
http.HandleFunc("/state", st.getState)
http.HandleFunc("/removeNode", st.removeNode)
Expand Down
9 changes: 6 additions & 3 deletions wiki/content/enterprise-features/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ forum](https://discuss.dgraph.io).

**Dgraph enterprise features are enabled by default for 30 days in a new cluster**.
After the trial period of thirty (30) days, the cluster must obtain a license from Dgraph to
continue enjoying the enterprise features released in the proprietary code. The license can
be applied to the cluster by including it as the body of a POST request and calling
`/enterpriseLicense` HTTP endpoint on any Zero server.
continue enjoying the enterprise features released in the proprietary code.

The license can be applied to the cluster by including it as the body of a POST
request and calling `/enterpriseLicense` HTTP endpoint on any Zero server. It
can also be applied by passing the path to the enterprise license file (using
the flag `--enterprise_license`) to the `dgraph zero` command used to start the
server. The second option is useful when the process needs to be automated.

{{% notice "note" %}}
At the conclusion of your 30-day trial period if a license has not been applied to the cluster,
Expand Down