-
Notifications
You must be signed in to change notification settings - Fork 432
Use load_definitions instead of management.load_definitions #430
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
Use load_definitions instead of management.load_definitions #430
Conversation
Since this only applies to Line 135 in 0c7faaf
Or maybe we could just point |
@yosifkit I'm afraid I'm not following. The need to update Since every series has its own Dockerfile, it makes sense to use it for version-specific bits as much as possible. Definition import does support directories but IIRC it is still an undocumented feature we have added for our own future product needs. Do you mean "point it at a file"? |
If we statically point it at a file and the user doesn't provide one, it will throw an error, right? (That was my reading of the associated code, which is where I found the ability to provide a directory and saw that an empty directory shouldn't error, so setting it statically to something like |
True, we validate all file paths for existence. Pointing it at a directory won't error. 3.7 won't recognize this key at all as it's never been backported and not in the config schema. I'd rather find a way to control this setting in Dockerfile is possible. |
Using a convention-based |
For backwards compatibility, I think we use this approach (if the file exists, we set Here's my proposed diff (against #422 because it makes similar changes and that makes the diff smaller), which keeps 3.7 doing exactly what it does today and keeps 3.8 backwards-compatible but using the newer parameter when the file exists, but always includes $ GIT_PAGER=cat git diff Dockerfile* docker-entrypoint.sh update.sh
diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template
index f29ac98..3f9038e 100644
--- a/Dockerfile-alpine.template
+++ b/Dockerfile-alpine.template
@@ -231,6 +231,8 @@ RUN set -eux; \
rm "$RABBITMQ_DATA_DIR/.erlang.cookie"
# Enable Prometheus-style metrics by default (https://github.com/docker-library/rabbitmq/issues/419)
RUN set -eux; rabbitmq-plugins enable --offline rabbitmq_prometheus; echo 'management_agent.disable_metrics_collector = true' > /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf
+# Enable "load_definitions" by default (https://github.com/docker-library/rabbitmq/issues/429)
+RUN set -eux; mkdir /etc/rabbitmq/definitions.d; chown rabbitmq:rabbitmq /etc/rabbitmq/definitions.d; echo 'load_definitions = /etc/rabbitmq/definitions.d' > /etc/rabbitmq/conf.d/load_definitions.conf
# Added for backwards compatibility - users can simply COPY custom plugins to /plugins
RUN ln -sf /opt/rabbitmq/plugins /plugins
diff --git a/Dockerfile-ubuntu.template b/Dockerfile-ubuntu.template
index 84de22a..987193a 100644
--- a/Dockerfile-ubuntu.template
+++ b/Dockerfile-ubuntu.template
@@ -249,6 +249,8 @@ RUN set -eux; \
rm "$RABBITMQ_DATA_DIR/.erlang.cookie"
# Enable Prometheus-style metrics by default (https://github.com/docker-library/rabbitmq/issues/419)
RUN set -eux; rabbitmq-plugins enable --offline rabbitmq_prometheus; echo 'management_agent.disable_metrics_collector = true' > /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf
+# Enable "load_definitions" by default (https://github.com/docker-library/rabbitmq/issues/429)
+RUN set -eux; mkdir /etc/rabbitmq/definitions.d; chown rabbitmq:rabbitmq /etc/rabbitmq/definitions.d; echo 'load_definitions = /etc/rabbitmq/definitions.d' > /etc/rabbitmq/conf.d/load_definitions.conf
# Added for backwards compatibility - users can simply COPY custom plugins to /plugins
RUN ln -sf /opt/rabbitmq/plugins /plugins
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 1b16604..ed0e2d8 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -387,7 +387,7 @@ if [ "$1" = 'rabbitmq-server' ] && [ "$shouldWriteConfig" ]; then
managementDefinitionsFile='/etc/rabbitmq/definitions.json'
if [ -f "$managementDefinitionsFile" ]; then
# see also https://github.com/docker-library/rabbitmq/pull/112#issuecomment-271485550
- rabbit_set_config 'management.load_definitions' "$managementDefinitionsFile"
+ rabbit_set_config 'load_definitions' "$managementDefinitionsFile"
fi
fi
fi
diff --git a/update.sh b/update.sh
index 365485f..10ac7aa 100755
--- a/update.sh
+++ b/update.sh
@@ -148,14 +148,19 @@ for version in "${versions[@]}"; do
# rabbitmq_prometheus is only included in 3.8+
# same with "/etc/rabbitmq/conf.d" support (https://github.com/rabbitmq/rabbitmq-server/pull/2258, https://github.com/rabbitmq/rabbitmq-server/pull/2277)
+ # same with "/etc/rabbitmq/definitions.d" support
if [ "$rcVersion" = '3.7' ]; then
sed -ri \
-e '/[Pp]rometheus/d' \
-e '/metrics_collector/d' \
-e 's/ 15691 15692 / /g' \
-e 's! /etc/rabbitmq/conf.d ! !g' \
+ -e '/load_definitions/d' \
"$version/$variant/Dockerfile" \
"$version/$variant/management/Dockerfile"
+ sed -ri \
+ -e 's/load_definitions/management.load_definitions/g' \
+ "$version/$variant/docker-entrypoint.sh"
fi
done
done |
@tianon this looks promising. So we will have a duplicate key? In that case, it's the "last update wins" IIRC but I need to try it. |
Yeah, we'll have a duplicate key, but only when they provide |
@tianon I have a radical (and beautiful in its simplicity) solution: let's just drop 3.7 support entirely for this image. 3.7 goes out of any kind of support on October 1st. There will be one more security patch release of |
Honestly, the attack |
That doesn't help us ditch this script, but it does push that conversation to be much more orthogonal! 😄 I've opened #431 for that deletion, assuming we don't get any dissenting votes. 😄 |
Just needs to be copied to the image build context directories (which |
@tianon is this something I can contribute to this image? This pretty trivial change is taking weeks to adopt :/ |
I'm sorry, I guess I needed to be more explicit in #430 (comment) -- the It could also use a rebase, but it was easy enough to ignore the 3.7-related changes |
Changes: - docker-library/rabbitmq@be3ec84: Merge pull request docker-library/rabbitmq#430 from michaelklishin/docker-image-429 - docker-library/rabbitmq@d1d424e: Apply template to image subdirectories
Thank you for the quick response 🙏 |
See #429 for the explanation of what the difference is and why this image should use the newer core mechanism (and not the original management plugin feature).
Closes #429.