Skip to content

Commit

Permalink
/health endpoint now shows EE Features available (#5293)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasssh authored Apr 27, 2020
1 parent 4dc4bd7 commit 51f8cfb
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 285 deletions.
20 changes: 11 additions & 9 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/dgraph-io/dgraph/chunker"
"github.com/dgraph-io/dgraph/conn"
"github.com/dgraph-io/dgraph/dgraph/cmd/zero"
"github.com/dgraph-io/dgraph/ee"
"github.com/dgraph-io/dgraph/gql"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
Expand Down Expand Up @@ -711,15 +712,16 @@ func (s *Server) Health(ctx context.Context, all bool) (*api.Response, error) {
}
// Append self.
healthAll = append(healthAll, pb.HealthInfo{
Instance: "alpha",
Address: x.WorkerConfig.MyAddr,
Status: "healthy",
Group: strconv.Itoa(int(worker.GroupId())),
Version: x.Version(),
Uptime: int64(time.Since(x.WorkerConfig.StartTime) / time.Second),
LastEcho: time.Now().Unix(),
Ongoing: worker.GetOngoingTasks(),
Indexing: schema.GetIndexingPredicates(),
Instance: "alpha",
Address: x.WorkerConfig.MyAddr,
Status: "healthy",
Group: strconv.Itoa(int(worker.GroupId())),
Version: x.Version(),
Uptime: int64(time.Since(x.WorkerConfig.StartTime) / time.Second),
LastEcho: time.Now().Unix(),
Ongoing: worker.GetOngoingTasks(),
Indexing: schema.GetIndexingPredicates(),
EeFeatures: ee.GetEEFeaturesList(),
})

var err error
Expand Down
24 changes: 24 additions & 0 deletions ee/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// +build oss

/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ee

// GetEEFeaturesList returns a list Enterprise Features that are available.
func GetEEFeaturesList() []string {
return nil
}
40 changes: 40 additions & 0 deletions ee/utils_ee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// +build !oss

/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ee

import (
"github.com/dgraph-io/dgraph/worker"
)

// GetEEFeaturesList returns a list of Enterprise Features that are available.
func GetEEFeaturesList() []string {
if !worker.EnterpriseEnabled() {
return nil
}
var ee []string
if len(worker.Config.HmacSecret) > 0 {
ee = append(ee, "acl")
}
if worker.Config.BadgerKeyFile != "" {
ee = append(ee, "encryption_at_rest", "encrypted_backup_restore", "encrypted_export")
} else {
ee = append(ee, "backup_restore")
}
return ee
}
1 change: 1 addition & 0 deletions protos/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ message HealthInfo {
int64 lastEcho = 7;
repeated string ongoing = 8;
repeated string indexing = 9;
repeated string ee_features = 10;
}

message Tablet {
Expand Down
Loading

0 comments on commit 51f8cfb

Please sign in to comment.