Skip to content

Commit 513a0ad

Browse files
committed
Added --rocksdb.encryption-keyfile option
1 parent c1ae3e8 commit 513a0ad

File tree

7 files changed

+104
-92
lines changed

7 files changed

+104
-92
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changes from version 0.7.0 to master
22

3+
- Added `--rocksdb.encryption-keyfile` option.
34
- Added pass through options. See README.
45
- Changed `--data.dir` option to `--starter.data-dir`
56

main.go

Lines changed: 69 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,41 @@ var (
6060
Short: "Start ArangoDB clusters & single servers with ease",
6161
Run: cmdMainRun,
6262
}
63-
log = logging.MustGetLogger(projectName)
64-
id string
65-
agencySize int
66-
arangodPath string
67-
arangodJSPath string
68-
masterPort int
69-
rrPath string
70-
startCoordinator bool
71-
startDBserver bool
72-
startLocalSlaves bool
73-
mode string
74-
dataDir string
75-
ownAddress string
76-
masterAddress string
77-
verbose bool
78-
serverThreads int
79-
serverStorageEngine string
80-
allPortOffsetsUnique bool
81-
jwtSecretFile string
82-
sslKeyFile string
83-
sslAutoKeyFile bool
84-
sslAutoServerName string
85-
sslAutoOrganization string
86-
sslCAFile string
87-
dockerEndpoint string
88-
dockerImage string
89-
dockerStarterImage = defaultDockerStarterImage
90-
dockerUser string
91-
dockerContainerName string
92-
dockerGCDelay time.Duration
93-
dockerNetHost bool // Deprecated
94-
dockerNetworkMode string
95-
dockerPrivileged bool
96-
passthroughOptions = make(map[string]*service.PassthroughOption)
63+
log = logging.MustGetLogger(projectName)
64+
id string
65+
agencySize int
66+
arangodPath string
67+
arangodJSPath string
68+
masterPort int
69+
rrPath string
70+
startCoordinator bool
71+
startDBserver bool
72+
startLocalSlaves bool
73+
mode string
74+
dataDir string
75+
ownAddress string
76+
masterAddress string
77+
verbose bool
78+
serverThreads int
79+
serverStorageEngine string
80+
allPortOffsetsUnique bool
81+
jwtSecretFile string
82+
sslKeyFile string
83+
sslAutoKeyFile bool
84+
sslAutoServerName string
85+
sslAutoOrganization string
86+
sslCAFile string
87+
rocksDBEncryptionKeyFile string
88+
dockerEndpoint string
89+
dockerImage string
90+
dockerStarterImage = defaultDockerStarterImage
91+
dockerUser string
92+
dockerContainerName string
93+
dockerGCDelay time.Duration
94+
dockerNetHost bool // Deprecated
95+
dockerNetworkMode string
96+
dockerPrivileged bool
97+
passthroughOptions = make(map[string]*service.PassthroughOption)
9798

9899
maskAny = errors.WithStack
99100
)
@@ -121,6 +122,7 @@ func init() {
121122
f.StringVar(&rrPath, "server.rr", "", "Path of rr")
122123
f.IntVar(&serverThreads, "server.threads", 0, "Adjust server.threads of each server")
123124
f.StringVar(&serverStorageEngine, "server.storage-engine", "mmfiles", "Type of storage engine to use (mmfiles|rocksdb) (3.2 and up)")
125+
f.StringVar(&rocksDBEncryptionKeyFile, "rocksdb.encryption-keyfile", "", "Key file used for RocksDB encryption. (Enterprise Edition 3.2 and up)")
124126

125127
f.StringVar(&dockerEndpoint, "docker.endpoint", "unix:///var/run/docker.sock", "Endpoint used to reach the docker daemon")
126128
f.StringVar(&dockerImage, "docker.image", getEnvVar("DOCKER_IMAGE", ""), "name of the Docker image to use to launch arangod instances (leave empty to avoid using docker)")
@@ -358,6 +360,7 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
358360
jwtSecretFile = mustExpand(jwtSecretFile)
359361
sslKeyFile = mustExpand(sslKeyFile)
360362
sslCAFile = mustExpand(sslCAFile)
363+
rocksDBEncryptionKeyFile = mustExpand(rocksDBEncryptionKeyFile)
361364

362365
// Check database executable
363366
if !runningInDocker {
@@ -420,37 +423,38 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
420423

421424
// Create service
422425
serviceConfig := service.Config{
423-
ID: id,
424-
Mode: mode,
425-
AgencySize: agencySize,
426-
ArangodPath: arangodPath,
427-
ArangodJSPath: arangodJSPath,
428-
MasterPort: masterPort,
429-
RrPath: rrPath,
430-
StartCoordinator: startCoordinator,
431-
StartDBserver: startDBserver,
432-
StartLocalSlaves: startLocalSlaves,
433-
DataDir: dataDir,
434-
OwnAddress: ownAddress,
435-
MasterAddress: masterAddress,
436-
Verbose: verbose,
437-
ServerThreads: serverThreads,
438-
ServerStorageEngine: serverStorageEngine,
439-
AllPortOffsetsUnique: allPortOffsetsUnique,
440-
JwtSecret: jwtSecret,
441-
SslKeyFile: sslKeyFile,
442-
SslCAFile: sslCAFile,
443-
RunningInDocker: isRunningInDocker(),
444-
DockerContainerName: dockerContainerName,
445-
DockerEndpoint: dockerEndpoint,
446-
DockerImage: dockerImage,
447-
DockerStarterImage: dockerStarterImage,
448-
DockerUser: dockerUser,
449-
DockerGCDelay: dockerGCDelay,
450-
DockerNetworkMode: dockerNetworkMode,
451-
DockerPrivileged: dockerPrivileged,
452-
ProjectVersion: projectVersion,
453-
ProjectBuild: projectBuild,
426+
ID: id,
427+
Mode: mode,
428+
AgencySize: agencySize,
429+
ArangodPath: arangodPath,
430+
ArangodJSPath: arangodJSPath,
431+
MasterPort: masterPort,
432+
RrPath: rrPath,
433+
StartCoordinator: startCoordinator,
434+
StartDBserver: startDBserver,
435+
StartLocalSlaves: startLocalSlaves,
436+
DataDir: dataDir,
437+
OwnAddress: ownAddress,
438+
MasterAddress: masterAddress,
439+
Verbose: verbose,
440+
ServerThreads: serverThreads,
441+
ServerStorageEngine: serverStorageEngine,
442+
AllPortOffsetsUnique: allPortOffsetsUnique,
443+
JwtSecret: jwtSecret,
444+
SslKeyFile: sslKeyFile,
445+
SslCAFile: sslCAFile,
446+
RocksDBEncryptionKeyFile: rocksDBEncryptionKeyFile,
447+
RunningInDocker: isRunningInDocker(),
448+
DockerContainerName: dockerContainerName,
449+
DockerEndpoint: dockerEndpoint,
450+
DockerImage: dockerImage,
451+
DockerStarterImage: dockerStarterImage,
452+
DockerUser: dockerUser,
453+
DockerGCDelay: dockerGCDelay,
454+
DockerNetworkMode: dockerNetworkMode,
455+
DockerPrivileged: dockerPrivileged,
456+
ProjectVersion: projectVersion,
457+
ProjectBuild: projectBuild,
454458
}
455459
for _, ptOpt := range passthroughOptions {
456460
serviceConfig.PassthroughOptions = append(serviceConfig.PassthroughOptions, *ptOpt)

service/arangodb.go

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,28 @@ const (
5050

5151
// Config holds all configuration for a single service.
5252
type Config struct {
53-
ID string // Unique identifier of this peer
54-
Mode string // Service mode cluster|single
55-
AgencySize int
56-
ArangodPath string
57-
ArangodJSPath string
58-
MasterPort int
59-
RrPath string
60-
StartCoordinator bool
61-
StartDBserver bool
62-
StartLocalSlaves bool // If set, start sufficient slave (Service's) locally.
63-
DataDir string
64-
OwnAddress string // IP address of used to reach this process
65-
MasterAddress string
66-
Verbose bool
67-
ServerThreads int // If set to something other than 0, this will be added to the commandline of each server with `--server.threads`...
68-
ServerStorageEngine string // mmfiles | rocksdb
69-
AllPortOffsetsUnique bool // If set, all peers will get a unique port offset. If false (default) only portOffset+peerAddress pairs will be unique.
70-
JwtSecret string
71-
SslKeyFile string // Path containing an x509 certificate + private key to be used by the servers.
72-
SslCAFile string // Path containing an x509 CA certificate used to authenticate clients.
73-
PassthroughOptions []PassthroughOption
53+
ID string // Unique identifier of this peer
54+
Mode string // Service mode cluster|single
55+
AgencySize int
56+
ArangodPath string
57+
ArangodJSPath string
58+
MasterPort int
59+
RrPath string
60+
StartCoordinator bool
61+
StartDBserver bool
62+
StartLocalSlaves bool // If set, start sufficient slave (Service's) locally.
63+
DataDir string
64+
OwnAddress string // IP address of used to reach this process
65+
MasterAddress string
66+
Verbose bool
67+
ServerThreads int // If set to something other than 0, this will be added to the commandline of each server with `--server.threads`...
68+
ServerStorageEngine string // mmfiles | rocksdb
69+
AllPortOffsetsUnique bool // If set, all peers will get a unique port offset. If false (default) only portOffset+peerAddress pairs will be unique.
70+
JwtSecret string
71+
SslKeyFile string // Path containing an x509 certificate + private key to be used by the servers.
72+
SslCAFile string // Path containing an x509 CA certificate used to authenticate clients.
73+
RocksDBEncryptionKeyFile string // Path containing encryption key for RocksDB encryption.
74+
PassthroughOptions []PassthroughOption
7475

7576
DockerContainerName string // Name of the container running this process
7677
DockerEndpoint string // Where to reach the docker daemon
@@ -417,6 +418,10 @@ func (s *Service) makeBaseArgs(myHostDir, myContainerDir string, myAddress strin
417418
options = append(options,
418419
optionPair{"--server.threads", strconv.Itoa(s.ServerThreads)})
419420
}
421+
if s.RocksDBEncryptionKeyFile != "" {
422+
options = append(options,
423+
optionPair{"--rocksdb.encryption-keyfile", s.RocksDBEncryptionKeyFile})
424+
}
420425
myTCPURL := scheme + "://" + net.JoinHostPort(myAddress, myPort)
421426
switch serverType {
422427
case ServerTypeAgent:
@@ -555,7 +560,7 @@ func (s *Service) startArangod(runner Runner, myHostAddress string, serverType S
555560
}
556561

557562
s.log.Infof("Starting %s on port %d", serverType, myPort)
558-
myContainerDir := runner.GetContainerDir(myHostDir)
563+
myContainerDir := runner.GetContainerDir(myHostDir, dockerDataDir)
559564
args, vols := s.makeBaseArgs(myHostDir, myContainerDir, myHostAddress, strconv.Itoa(myPort), serverType)
560565
vols = addDataVolumes(vols, myHostDir, myContainerDir)
561566
s.writeCommand(filepath.Join(myHostDir, "arangod_command.txt"), s.serverExecutable(), args)

service/passthrough.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ var (
4949
"database.directory",
5050
"javascript.startup-directory",
5151
"javascript.app-path",
52+
"rocksdb.encryption-keyfile",
5253
"server.endpoint",
5354
"server.authentication",
5455
"server.jwt-secret",

service/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Volume struct {
3030

3131
type Runner interface {
3232
// Map the given host directory to a container directory
33-
GetContainerDir(hostDir string) string
33+
GetContainerDir(hostDir, defaultContainerDir string) string
3434

3535
// GetRunningServer checks if there is already a server process running in the given server directory.
3636
// If that is the case, its process is returned.

service/runner_docker.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const (
4343
containerFileName = "CONTAINER"
4444
createdByKey = "created-by"
4545
createdByValue = "arangodb-starter"
46+
dockerDataDir = "/data"
4647
)
4748

4849
// NewDockerRunner creates a runner that starts processes in a docker container.
@@ -84,11 +85,11 @@ type dockerContainer struct {
8485
container *docker.Container
8586
}
8687

87-
func (r *dockerRunner) GetContainerDir(hostDir string) string {
88+
func (r *dockerRunner) GetContainerDir(hostDir, defaultContainerDir string) string {
8889
if r.volumesFrom != "" {
8990
return hostDir
9091
}
91-
return "/data"
92+
return defaultContainerDir
9293
}
9394

9495
// GetRunningServer checks if there is already a server process running in the given server directory.
@@ -283,7 +284,7 @@ func (r *dockerRunner) CreateStartArangodbCommand(myDataDir string, index int, m
283284
}
284285
lines := []string{
285286
fmt.Sprintf("docker volume create arangodb%d &&", index),
286-
fmt.Sprintf("docker run -it --name=adb%d --rm %s -v arangodb%d:/data", index, netArgs, index),
287+
fmt.Sprintf("docker run -it --name=adb%d --rm %s -v arangodb%d:%s", index, netArgs, index, dockerDataDir),
287288
fmt.Sprintf("-v /var/run/docker.sock:/var/run/docker.sock %s", starterImageName),
288289
fmt.Sprintf("--starter.address=%s --starter.join=%s", masterIP, addr),
289290
}

service/runner_process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type process struct {
5555
isChild bool
5656
}
5757

58-
func (r *processRunner) GetContainerDir(hostDir string) string {
58+
func (r *processRunner) GetContainerDir(hostDir, defaultContainerDir string) string {
5959
return hostDir
6060
}
6161

0 commit comments

Comments
 (0)