diff --git a/docker-image-src/3.3/docker-entrypoint.sh b/docker-image-src/3.3/docker-entrypoint.sh index 573471d5..86c86d35 100755 --- a/docker-image-src/3.3/docker-entrypoint.sh +++ b/docker-image-src/3.3/docker-entrypoint.sh @@ -243,9 +243,6 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi - : ${NEO4J_wrapper_java_additional:=-Dneo4j.ext.udc.source=docker} - : ${NEO4J_dbms_jvm_additional:=-Dunsupported.dbms.udc.source=docker} - # unset old hardcoded unsupported env variables unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ @@ -372,6 +369,17 @@ for conf in ${!ENTERPRISE[@]} ; do fi done +#The udc.source=tarball should be replaced by udc.source=docker in both dbms.jvm.additional and wrapper.java.additional +#Using sed to replace only this part will allow the custom configs to be added after, separated by a ,. +if grep -q "udc.source=tarball" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/udc.source=tarball/udc.source=docker/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi +#The udc.source should always be set to docker by default and we have to allow also custom configs to be added after that. +#In this case, this piece of code helps to add the default value and a , to support custom configs after. +if ! grep -q "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/dbms.jvm.additional=/dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi + # list env variables with prefix NEO4J_ and create settings from them unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do diff --git a/docker-image-src/3.4/docker-entrypoint.sh b/docker-image-src/3.4/docker-entrypoint.sh index ae0c3444..86c86d35 100755 --- a/docker-image-src/3.4/docker-entrypoint.sh +++ b/docker-image-src/3.4/docker-entrypoint.sh @@ -243,8 +243,6 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi - : ${NEO4J_wrapper_java_additional:=-Dneo4j.ext.udc.source=docker} - : ${NEO4J_dbms_jvm_additional:=-Dunsupported.dbms.udc.source=docker} # unset old hardcoded unsupported env variables unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ @@ -371,6 +369,17 @@ for conf in ${!ENTERPRISE[@]} ; do fi done +#The udc.source=tarball should be replaced by udc.source=docker in both dbms.jvm.additional and wrapper.java.additional +#Using sed to replace only this part will allow the custom configs to be added after, separated by a ,. +if grep -q "udc.source=tarball" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/udc.source=tarball/udc.source=docker/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi +#The udc.source should always be set to docker by default and we have to allow also custom configs to be added after that. +#In this case, this piece of code helps to add the default value and a , to support custom configs after. +if ! grep -q "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/dbms.jvm.additional=/dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi + # list env variables with prefix NEO4J_ and create settings from them unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do diff --git a/docker-image-src/3.5/docker-entrypoint.sh b/docker-image-src/3.5/docker-entrypoint.sh index 77721d11..ed6bd504 100755 --- a/docker-image-src/3.5/docker-entrypoint.sh +++ b/docker-image-src/3.5/docker-entrypoint.sh @@ -239,8 +239,6 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi - : ${NEO4J_wrapper_java_additional:=-Dneo4j.ext.udc.source=docker} - : ${NEO4J_dbms_jvm_additional:=-Dunsupported.dbms.udc.source=docker} # unset old hardcoded unsupported env variables unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ @@ -367,6 +365,17 @@ for conf in ${!ENTERPRISE[@]} ; do fi done +#The udc.source=tarball should be replaced by udc.source=docker in both dbms.jvm.additional and wrapper.java.additional +#Using sed to replace only this part will allow the custom configs to be added after, separated by a ,. +if grep -q "udc.source=tarball" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/udc.source=tarball/udc.source=docker/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi +#The udc.source should always be set to docker by default and we have to allow also custom configs to be added after that. +#In this case, this piece of code helps to add the default value and a , to support custom configs after. +if ! grep -q "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/dbms.jvm.additional=/dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi + # list env variables with prefix NEO4J_ and create settings from them unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do diff --git a/docker-image-src/4.0/docker-entrypoint.sh b/docker-image-src/4.0/docker-entrypoint.sh index 00f1256e..7bca3832 100755 --- a/docker-image-src/4.0/docker-entrypoint.sh +++ b/docker-image-src/4.0/docker-entrypoint.sh @@ -239,9 +239,6 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi - : ${NEO4J_wrapper_java_additional:=-Dneo4j.ext.udc.source=docker} - : ${NEO4J_dbms_jvm_additional:=-Dunsupported.dbms.udc.source=docker} - # unset old hardcoded unsupported env variables unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ @@ -368,6 +365,17 @@ for conf in ${!ENTERPRISE[@]} ; do fi done +#The udc.source=tarball should be replaced by udc.source=docker in both dbms.jvm.additional and wrapper.java.additional +#Using sed to replace only this part will allow the custom configs to be added after, separated by a ,. +if grep -q "udc.source=tarball" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/udc.source=tarball/udc.source=docker/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi +#The udc.source should always be set to docker by default and we have to allow also custom configs to be added after that. +#In this case, this piece of code helps to add the default value and a , to support custom configs after. +if ! grep -q "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker" "${NEO4J_HOME}"/conf/neo4j.conf; then + sed -i -e 's/dbms.jvm.additional=/dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,/g' "${NEO4J_HOME}"/conf/neo4j.conf +fi + # list env variables with prefix NEO4J_ and create settings from them unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do diff --git a/src/test/java/com/neo4j/docker/TestConfSettings.java b/src/test/java/com/neo4j/docker/TestConfSettings.java index ff140ede..505b5d79 100644 --- a/src/test/java/com/neo4j/docker/TestConfSettings.java +++ b/src/test/java/com/neo4j/docker/TestConfSettings.java @@ -269,4 +269,26 @@ void testCommunityDoesNotHaveEnterpriseConfigs() throws Exception lines.close(); Assertions.assertFalse(ccNotPresent.isPresent(), "causal_clustering.transaction_listen_address should not be on the Community debug.log"); } + @Test + void testJvmAdditionalNotOverriden() throws Exception + { + //Create container + container = createContainer(); + //Mount /conf + Path confMount = HostFileSystemOperations.createTempFolderAndMountAsVolume(container, "conf-", "/conf"); + Path logMount = HostFileSystemOperations.createTempFolderAndMountAsVolume(container, "logs-", "/logs"); + SetContainerUser.nonRootUser(container); + //Create JvmAdditionalNotOverriden.conf file + Path confFile = Paths.get("src", "test", "resources", "confs", "JvmAdditionalNotOverriden.conf"); + Files.copy(confFile, confMount.resolve("neo4j.conf")); + //Start the container + container.setWaitStrategy(Wait.forHttp("/").forPort(7474).forStatusCode(200)); + container.start(); + + //Read the debug.log to check that dbms.jvm.additional was set correctly + Stream lines = Files.lines(logMount.resolve("debug.log")); + Optional jvmAdditionalMatch = lines.filter(s -> s.contains("dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")).findFirst(); + lines.close(); + Assertions.assertTrue(jvmAdditionalMatch.isPresent(), "dbms.jvm.additional was is overriden by docker-entrypoint"); + } } \ No newline at end of file diff --git a/src/test/resources/confs/JvmAdditionalNotOverriden.conf b/src/test/resources/confs/JvmAdditionalNotOverriden.conf new file mode 100644 index 00000000..4499c4f9 --- /dev/null +++ b/src/test/resources/confs/JvmAdditionalNotOverriden.conf @@ -0,0 +1 @@ +dbms.jvm.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 \ No newline at end of file