Skip to content

Commit 7ba7298

Browse files
Add rocksdb.encryption-key-generator CLI option (#348)
Co-authored-by: Adam Janikowski <[email protected]>
1 parent d8182d4 commit 7ba7298

File tree

6 files changed

+53
-38
lines changed

6 files changed

+53
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Improve detection of arangod binary when running local installation (use --server.use-local-bin)
66
- Upgrade base Alpine image and Go dependencies to fix CVEs
77
- Remove `netgo` build tag for Windows to disable new Go resolver behaviour: https://github.com/golang/go/issues/57757
8+
- Add `rocksdb.encryption-key-generator` CLI option
89

910
## [0.15.6](https://github.com/arangodb-helper/arangodb/tree/0.15.6) (2023-01-20)
1011
- Fix restarting cluster with arangosync enabled

main.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func init() {
175175
f.StringVar(&opts.server.storageEngine, "server.storage-engine", "", "Type of storage engine to use (mmfiles|rocksdb) (3.2 and up)")
176176

177177
f.StringVar(&opts.rocksDB.encryptionKeyFile, "rocksdb.encryption-keyfile", "", "Key file used for RocksDB encryption. (Enterprise Edition 3.2 and up)")
178+
f.StringVar(&opts.rocksDB.encryptionKeyGenerator, "rocksdb.encryption-key-generator", "", "Path to program. The output of this program will be used as key for RocksDB encryption. (Enterprise Edition)")
178179

179180
f.StringVar(&opts.docker.endpoint, "docker.endpoint", "unix:///var/run/docker.sock", "Endpoint used to reach the docker daemon")
180181
f.StringVar(&opts.docker.arangodImage, "docker.image", getEnvVar("DOCKER_IMAGE", ""), "name of the Docker image to use to launch arangod instances (leave empty to avoid using docker)")
@@ -576,6 +577,7 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
576577
opts.ssl.keyFile = mustExpand(opts.ssl.keyFile)
577578
opts.ssl.caFile = mustExpand(opts.ssl.caFile)
578579
opts.rocksDB.encryptionKeyFile = mustExpand(opts.rocksDB.encryptionKeyFile)
580+
opts.rocksDB.encryptionKeyGenerator = mustExpand(opts.rocksDB.encryptionKeyGenerator)
579581

580582
// Check database executable
581583
if !runningInDocker {
@@ -680,23 +682,24 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
680682

681683
// Create service
682684
bsCfg := service.BootstrapConfig{
683-
ID: opts.starter.id,
684-
Mode: service.ServiceMode(opts.starter.mode),
685-
DataDir: opts.starter.dataDir,
686-
AgencySize: opts.cluster.agencySize,
687-
StartLocalSlaves: opts.starter.startLocalSlaves,
688-
StartAgent: mustGetOptionalBoolRef("cluster.start-agent", opts.cluster.startAgent),
689-
StartDBserver: mustGetOptionalBoolRef("cluster.start-dbserver", opts.cluster.startDBServer),
690-
StartCoordinator: mustGetOptionalBoolRef("cluster.start-coordinator", opts.cluster.startCoordinator),
691-
StartResilientSingle: mustGetOptionalBoolRef("cluster.start-single", opts.cluster.startActiveFailover),
692-
StartSyncMaster: mustGetOptionalBoolRef("sync.start-master", opts.sync.startSyncMaster),
693-
StartSyncWorker: mustGetOptionalBoolRef("sync.start-worker", opts.sync.startSyncWorker),
694-
ServerStorageEngine: opts.server.storageEngine,
695-
JwtSecret: jwtSecret,
696-
SslKeyFile: opts.ssl.keyFile,
697-
SslCAFile: opts.ssl.caFile,
698-
RocksDBEncryptionKeyFile: opts.rocksDB.encryptionKeyFile,
699-
DisableIPv6: opts.starter.disableIPv6,
685+
ID: opts.starter.id,
686+
Mode: service.ServiceMode(opts.starter.mode),
687+
DataDir: opts.starter.dataDir,
688+
AgencySize: opts.cluster.agencySize,
689+
StartLocalSlaves: opts.starter.startLocalSlaves,
690+
StartAgent: mustGetOptionalBoolRef("cluster.start-agent", opts.cluster.startAgent),
691+
StartDBserver: mustGetOptionalBoolRef("cluster.start-dbserver", opts.cluster.startDBServer),
692+
StartCoordinator: mustGetOptionalBoolRef("cluster.start-coordinator", opts.cluster.startCoordinator),
693+
StartResilientSingle: mustGetOptionalBoolRef("cluster.start-single", opts.cluster.startActiveFailover),
694+
StartSyncMaster: mustGetOptionalBoolRef("sync.start-master", opts.sync.startSyncMaster),
695+
StartSyncWorker: mustGetOptionalBoolRef("sync.start-worker", opts.sync.startSyncWorker),
696+
ServerStorageEngine: opts.server.storageEngine,
697+
JwtSecret: jwtSecret,
698+
SslKeyFile: opts.ssl.keyFile,
699+
SslCAFile: opts.ssl.caFile,
700+
RocksDBEncryptionKeyFile: opts.rocksDB.encryptionKeyFile,
701+
RocksDBEncryptionKeyGenerator: opts.rocksDB.encryptionKeyGenerator,
702+
DisableIPv6: opts.starter.disableIPv6,
700703
}
701704
bsCfg.Initialize()
702705
serviceConfig := service.Config{

options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ type starterOptions struct {
8282
caFile string
8383
}
8484
rocksDB struct {
85-
encryptionKeyFile string
85+
encryptionKeyFile string
86+
encryptionKeyGenerator string
8687
}
8788
docker struct {
8889
endpoint string

service/arangod_config_builder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ func createArangodConf(log zerolog.Logger, bsCfg BootstrapConfig, myHostDir, myC
132132
}
133133
config = append(config, rocksdbSection)
134134
}
135+
if bsCfg.RocksDBEncryptionKeyGenerator != "" {
136+
rocksdbSection := &configSection{
137+
Name: "rocksdb",
138+
Settings: map[string]string{
139+
"encryption-key-generator": bsCfg.RocksDBEncryptionKeyGenerator,
140+
},
141+
}
142+
config = append(config, rocksdbSection)
143+
}
135144

136145
out, err := os.Create(hostConfFileName)
137146
if err != nil {

service/bootstrap_config.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,26 @@ import (
3232
// BootstrapConfig holds all configuration for a service that will
3333
// not change through the lifetime of a cluster.
3434
type BootstrapConfig struct {
35-
ID string // Unique identifier of this peer
36-
Mode ServiceMode // Service mode cluster|single
37-
DataDir string
38-
AgencySize int // Number of agents in the agency
39-
StartLocalSlaves bool // If set, start sufficient slave (Service's) locally.
40-
StartAgent *bool // If not nil, sets if starter starts a agent, otherwise default handling applies
41-
StartDBserver *bool // If not nil, sets if starter starts a dbserver, otherwise default handling applies
42-
StartCoordinator *bool // If not nil, sets if starter starts a coordinator, otherwise default handling applies
43-
StartResilientSingle *bool // If not nil, sets if starter starts a resilient single, otherwise default handling applies
44-
StartSyncMaster *bool // If not nil, sets if the starter starts a sync master, otherwise default handling applies
45-
StartSyncWorker *bool // If not nil, sets if the starter starts a sync worker, otherwise default handling applies
46-
ServerStorageEngine string // mmfiles | rocksdb
47-
JwtSecret string // JWT secret used for arangod communication
48-
ArangosyncMonitoringToken string // Bearer token used for arangosync authentication
49-
SslKeyFile string // Path containing an x509 certificate + private key to be used by the servers.
50-
SslCAFile string // Path containing an x509 CA certificate used to authenticate clients.
51-
RocksDBEncryptionKeyFile string // Path containing encryption key for RocksDB encryption.
52-
DisableIPv6 bool // If set, no IPv6 notation will be used
53-
RecoveryAgentID string `json:"-"` // ID of the agent. Only set during recovery
35+
ID string // Unique identifier of this peer
36+
Mode ServiceMode // Service mode cluster|single
37+
DataDir string
38+
AgencySize int // Number of agents in the agency
39+
StartLocalSlaves bool // If set, start sufficient slave (Service's) locally.
40+
StartAgent *bool // If not nil, sets if starter starts a agent, otherwise default handling applies
41+
StartDBserver *bool // If not nil, sets if starter starts a dbserver, otherwise default handling applies
42+
StartCoordinator *bool // If not nil, sets if starter starts a coordinator, otherwise default handling applies
43+
StartResilientSingle *bool // If not nil, sets if starter starts a resilient single, otherwise default handling applies
44+
StartSyncMaster *bool // If not nil, sets if the starter starts a sync master, otherwise default handling applies
45+
StartSyncWorker *bool // If not nil, sets if the starter starts a sync worker, otherwise default handling applies
46+
ServerStorageEngine string // mmfiles | rocksdb
47+
JwtSecret string // JWT secret used for arangod communication
48+
ArangosyncMonitoringToken string // Bearer token used for arangosync authentication
49+
SslKeyFile string // Path containing an x509 certificate + private key to be used by the servers.
50+
SslCAFile string // Path containing an x509 CA certificate used to authenticate clients.
51+
RocksDBEncryptionKeyFile string // Path containing encryption key for RocksDB encryption.
52+
RocksDBEncryptionKeyGenerator string // Path to program. The output of this program will be used as key for RocksDB encryption.
53+
DisableIPv6 bool // If set, no IPv6 notation will be used
54+
RecoveryAgentID string `json:"-"` // ID of the agent. Only set during recovery
5455
}
5556

5657
func (bsCfg BootstrapConfig) JWTFolderDir() string {

service/options/forbidden.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (f forbidden) IsForbidden(key string) bool {
3535
}
3636

3737
var (
38-
// forbiddenOptions holds a list of options that are not allowed to be overriden.
38+
// forbiddenOptions holds a list of options that are not allowed to be overridden.
3939
forbiddenOptions = forbidden{
4040
// Arangod
4141
"agency.activate",

0 commit comments

Comments
 (0)