mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Sensitive information protection (#1092)
This commit is contained in:
parent
de360d97fa
commit
46f7c1e4cc
7 changed files with 87 additions and 6 deletions
|
@ -20,6 +20,7 @@
|
|||
- (Feature) Immutable spec
|
||||
- (Bugfix) Proper agent cleanout
|
||||
- (Bugfix) Fix ClusterScaling integration
|
||||
- (Feature) Sensitive information protection
|
||||
|
||||
## [1.2.15](https://github.com/arangodb/kube-arangodb/tree/1.2.15) (2022-07-20)
|
||||
- (Bugfix) Ensure pod names not too long
|
||||
|
|
|
@ -37,6 +37,7 @@ const (
|
|||
TargetHotBackupKey = "HotBackup"
|
||||
|
||||
PlanCollectionsKey = "Collections"
|
||||
PlanDatabasesKey = "Databases"
|
||||
|
||||
SupervisionKey = "Supervision"
|
||||
SupervisionMaintenanceKey = "Maintenance"
|
||||
|
|
27
pkg/deployment/agency/plan_databases.go
Normal file
27
pkg/deployment/agency/plan_databases.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package agency
|
||||
|
||||
type PlanDatabases map[string]PlanDatabase
|
||||
|
||||
type PlanDatabase struct {
|
||||
ID string `json:"id"`
|
||||
}
|
35
pkg/deployment/agency/plan_databases_test.go
Normal file
35
pkg/deployment/agency/plan_databases_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package agency
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_Databases(t *testing.T) {
|
||||
var s DumpState
|
||||
require.NoError(t, json.Unmarshal(agencyDump39HotBackup, &s))
|
||||
|
||||
require.Contains(t, s.Agency.Arango.Plan.Databases, "_system")
|
||||
}
|
|
@ -44,6 +44,7 @@ func (c *cache) loadState(ctx context.Context, client agency.Agency) (State, err
|
|||
readKeys := []string{
|
||||
GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey),
|
||||
GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey),
|
||||
GetAgencyKey(ArangoKey, PlanKey, PlanDatabasesKey),
|
||||
GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey),
|
||||
GetAgencyKey(ArangoKey, CurrentKey, CurrentMaintenanceServers),
|
||||
GetAgencyKey(ArangoKey, TargetKey, TargetHotBackupKey),
|
||||
|
@ -107,6 +108,7 @@ type StateCurrent struct {
|
|||
|
||||
type StatePlan struct {
|
||||
Collections StatePlanCollections `json:"Collections"`
|
||||
Databases PlanDatabases `json:"Databases,omitempty"`
|
||||
}
|
||||
|
||||
type StateSupervision struct {
|
||||
|
|
|
@ -22,6 +22,7 @@ package features
|
|||
|
||||
func init() {
|
||||
registerFeature(ephemeralVolumes)
|
||||
registerFeature(sensitiveInformationProtection)
|
||||
}
|
||||
|
||||
var ephemeralVolumes = &feature{
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
|
||||
"github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||
|
@ -111,21 +112,34 @@ func (i *inventory) Collect(m chan<- prometheus.Metric) {
|
|||
|
||||
if spec.Mode.Get() == api.DeploymentModeCluster {
|
||||
for db, collections := range agency.Current.Collections {
|
||||
dbName := db
|
||||
if features.SensitiveInformationProtection().Enabled() {
|
||||
dbName = "UNKNOWN"
|
||||
|
||||
if v, ok := agency.Plan.Databases[db]; ok && v.ID != "" {
|
||||
dbName = v.ID
|
||||
}
|
||||
}
|
||||
|
||||
for collection, shards := range collections {
|
||||
for shard, details := range shards {
|
||||
for id, server := range details.Servers {
|
||||
name := "UNKNOWN"
|
||||
if _, ok := agency.Plan.Collections[db]; ok {
|
||||
if _, ok := agency.Plan.Collections[db][collection]; ok {
|
||||
name = agency.Plan.Collections[db][collection].GetName(name)
|
||||
collectionName := "UNKNOWN"
|
||||
if features.SensitiveInformationProtection().Enabled() {
|
||||
collectionName = collection
|
||||
} else {
|
||||
if _, ok := agency.Plan.Collections[db]; ok {
|
||||
if _, ok := agency.Plan.Collections[db][collection]; ok {
|
||||
collectionName = agency.Plan.Collections[db][collection].GetName(collectionName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m := []string{
|
||||
deployment.GetNamespace(),
|
||||
deployment.GetName(),
|
||||
db,
|
||||
name,
|
||||
dbName,
|
||||
collectionName,
|
||||
shard,
|
||||
string(server),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue