Skip to content

Add support for read-only config file mounts #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions 3.7-rc/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions 3.7-rc/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions 3.7/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions 3.7/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions 3.8-rc/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions 3.8-rc/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down
10 changes: 10 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config"
newConfigFile="$configBase.conf"

shouldWriteConfig="$haveConfig"
if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then
# config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap)
export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf'
cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE"
echo >&2
echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it"
echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead."
echo >&2
newConfigFile="$RABBITMQ_CONFIG_FILE"
fi
if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then
{
echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"
Expand Down