@@ -25,6 +25,7 @@ package k8sutil
2525import (
2626 "fmt"
2727 "path/filepath"
28+ "strings"
2829 "time"
2930
3031 "k8s.io/api/core/v1"
@@ -170,13 +171,28 @@ func rocksdbEncryptionVolumeMounts() []v1.VolumeMount {
170171
171172// arangodInitContainer creates a container configured to
172173// initalize a UUID file.
173- func arangodInitContainer (name , id string ) v1.Container {
174+ func arangodInitContainer (name , id , engine string , requireUUID bool ) v1.Container {
174175 uuidFile := filepath .Join (ArangodVolumeMountDir , "UUID" )
176+ engineFile := filepath .Join (ArangodVolumeMountDir , "ENGINE" )
177+ var command string
178+ if requireUUID {
179+ command = strings .Join ([]string {
180+ // Files must exist
181+ fmt .Sprintf ("test -f %s" , uuidFile ),
182+ fmt .Sprintf ("test -f %s" , engineFile ),
183+ // Content must match
184+ fmt .Sprintf ("grep -q %s %s" , id , uuidFile ),
185+ fmt .Sprintf ("grep -q %s %s" , engine , engineFile ),
186+ }, " && " )
187+
188+ } else {
189+ command = fmt .Sprintf ("test -f %s || echo '%s' > %s" , uuidFile , id , uuidFile )
190+ }
175191 c := v1.Container {
176192 Command : []string {
177193 "/bin/sh" ,
178194 "-c" ,
179- fmt . Sprintf ( "test -f %s || echo '%s' > %s" , uuidFile , id , uuidFile ) ,
195+ command ,
180196 },
181197 Name : name ,
182198 Image : alpineImage ,
@@ -261,6 +277,7 @@ func newPod(deploymentName, ns, role, id, podName string) v1.Pod {
261277// If another error occurs, that error is returned.
262278func CreateArangodPod (kubecli kubernetes.Interface , developmentMode bool , deployment APIObject ,
263279 role , id , podName , pvcName , image string , imagePullPolicy v1.PullPolicy ,
280+ engine string , requireUUID bool ,
264281 args []string , env map [string ]EnvValue ,
265282 livenessProbe * HTTPProbeConfig , readinessProbe * HTTPProbeConfig ,
266283 tlsKeyfileSecretName , rocksdbEncryptionSecretName string ) error {
@@ -278,7 +295,7 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
278295 p .Spec .Containers = append (p .Spec .Containers , c )
279296
280297 // Add UUID init container
281- p .Spec .InitContainers = append (p .Spec .InitContainers , arangodInitContainer ("uuid" , id ))
298+ p .Spec .InitContainers = append (p .Spec .InitContainers , arangodInitContainer ("uuid" , id , engine , requireUUID ))
282299
283300 // Add volume
284301 if pvcName != "" {
0 commit comments