janusgraph-docker
janusgraph-docker copied to clipboard
Container is not terminated on failure of docker-entrypoint-initdb.d groovy scripts
I've written graph initialisation groovy script and mounted to docker-entrypoint-initdb.d. I'm expecting that the container will terminate if the script throws any exception.
Since I'm using kubernetes, if the script fails with some connection error and the container is not terminated, kubernetes will not try to restart it.
Is it the default behaviour of this image or do I need to configure something so that the container is terminated if initialisation script fails
I will check it in the next day. Could you provide some more information? Config, docker image tag, ...
Below is the configuration
image: "janusgraph/janusgraph:0.5.2"
imagePullPolicy: Always
env:
- name: JANUS_PROPS_TEMPLATE
value: "cql-es"
- name: janusgraph.storage.hostname
value: "cassandra"
- name: janusgraph.index.search.hostname
value: "elasticsearch"
- name: janusgraph.storage.cql.keyspace
value: "search"
volumeMounts:
- name: initdb
mountPath: /docker-entrypoint-initdb.d
and the configmap is as below
apiVersion: v1
kind: ConfigMap
metadata:
name: initdb-config
data:
initdb.groovy: |
:remote connect tinkerpop.server conf/remote.yaml session
:remote console
:remote config timeout 300000
println "Load graph"
GraphOfTheGodsFactory.load(graph)
println "Done!"
:exit
While this works is normal scenarios but in case when cassandra is not ready then janusgraph container fails to execute the initdb.groovy, which is also fine but the problem is the container is not stopped if the init scripts fails.
This is a problem because with container orchestration platforms such as kubernetes the idea is to fail the container if something critical goes wrong and the platform will restart it again. This helps handling scenarios where there are dependent services not started.
So in my case if the init scripts (initdb.groovy) fails there is no reason to start the container as the further operations will going to fails because of non initialised database
The container should kill itself if any error is occurred during init script execution or if any option is provided which helps stop the container if init script fails that will be very helpful.
This can also easily be reproduced with an init script that is already broken in itself, example:
c.doesnotexist()
I think we should fix this as the data should be really loaded when the container is up and running. Everything else is unexpected.
We probably have to use the exit code of load-initdb.sh and maybe add set -e at least in that script, but maybe also in docker-entrypoint.sh itself. I just played a bit with those two scripts, but couldn't get it to work. I guess my Bash skills are too limited 😞
If anyone wants to tackle this, a PR would of course be very welcome 😃