Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Container is not terminated on failure of docker-entrypoint-initdb.d groovy scripts #76

Open
vivekweb2013 opened this issue Jan 26, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@vivekweb2013
Copy link

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

@farodin91
Copy link
Contributor

I will check it in the next day. Could you provide some more information? Config, docker image tag, ...

@vivekweb2013
Copy link
Author

vivekweb2013 commented Feb 20, 2021

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.

@FlorianHockmann
Copy link
Member

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 😃

@FlorianHockmann FlorianHockmann added the help wanted Extra attention is needed label Jun 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants