-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[FLINK-20915][docker] Move docker entrypoint to distribution #14630
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 73767fc (Wed Jan 13 10:35:35 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether it makes sense to rename the script. docker-entrypoint.sh
is usually the name of the "main method" of a Docker Image.
maybe we need to establish the concept of flink-docker/docker-entrypoint.sh being the "wrapper" that sets up the environment, and this one being the "docker-entrypoint-runner.sh" ?
Just thoughts ...
############################################################################### | ||
|
||
COMMAND_STANDALONE="standalone-job" | ||
# Deprecated, should be remove in Flink release 1.13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Deprecated, should be remove in Flink release 1.13 | |
# Deprecated, should be removed in Flink release 1.13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is against master, which will eventually become release 1.13?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only moving the script, any logic/API changes should be relegated to follow-ups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the master branch, the native K8s will not need the native-k8s
command anymore. It will generate the command and arguments as followings.
- args:
- bash
- -c
- $JAVA_HOME/bin/java -classpath $FLINK_CLASSPATH -Xmx1073741824 -Xms1073741824
-XX:MaxMetaspaceSize=268435456 -Dlog.file=/opt/flink/log/jobmanager.log -Dlogback.configurationFile=file:/opt/flink/conf/logback-console.xml
-Dlog4j.configuration=file:/opt/flink/conf/log4j2.xml -Dlog4j.configurationFile=file:/opt/flink/conf/log4j2.xml
org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint
...
command:
- /docker-entrypoint.sh
We already have a ticket FLINK-20676 to track this.
@@ -0,0 +1,161 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script shows up in build-target/bin
. If we keep it there, we need to add a message that it shall not be used manually.
Maybe, it makes sense to move the script to opt/docker/docker-entrypoint.sh
to not further pollute bin/
? (This is really just a thought for discussion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a lot of stuff in bin/ at this point that users should never use directly (bash-java-utils, config.sh, flink-console.sh, flink-daemon.sh, find-flink-home.sh), that I'm not too concerned about adding one more.
I see the point of trying to hide it, but this whole "put-into-opt-but-load-it-automatically-in-some-scenarios" business that the table-api introduced is rubbing me the wrong way.
The overall semantics for bin/opt seem rather ill-defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. We should clean up the bin directory in a separate effort.
Yeah I wasn't sure either about the naming business. I'm not too bothered by the current name, and think that entrypoint-runner is a bit misleading since I would would assume the runner would call the entrypoint. |
COMMAND_HISTORY_SERVER="history-server" | ||
|
||
args=("$@") | ||
echo "${args[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not print any text in the pass-through mode. Otherwise, the PR for docker-library/official-images will fail since CI will run the this test[1].
[1]. https://github.com/docker-library/official-images/blob/master/test/tests/override-cmd/run.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, this was for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for creating this PR.
The only concern I have is about the counterpart change in flink-docker project. I am not sure using such a wrapper is reasonable for those docker guys. In my opinion, now the docker image is more like a blackbox and I have to check the docker-entrypoint.sh
in flink project for how to use it.
exec $(drop_privs_cmd) "${FLINK_HOME}/bin/docker-entrypoint.sh" "${args[@]}"
@wangyang0918 I have outlined this approach and already gotten their approval. docker-library/official-images#9249 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this.
I assume you've tested the changes manually. I haven't.
I've only run CI; which should at least cover all branches. I think I broke the jmalloc switch, because it checks the wrong argument. Of course we don't have tests for that; why should you... |
@flinkbot run azure |
To clarify - I did not mean simply moving the entrypoint script into Flink. I meant moving the functionality into Flink. Many of the things that happen in that script are things that probably make sense for other (non-container) users of Flink as well, and it feels wrong for those implementations to happen in the Dockerization scripts. |
It seems that we are still not on the same page. |
@tianon This is just a first step to facilitate easier refactorings. Migrating more (ideally all) of the docker-specific logic into the scripts is the long-term goal, which would be hampered if we'd have to move things bit by bit from one repo (flink-docker) to another (flink). In any case moving this script into the distribution should already be an overall plus because this logic is now at least accessible even outside docker use-cases. |
I agree that the Docker image being a complete black box is a bad thing, which is exactly why I'm confused by this PR. Let me try to rephrase what I'm suggesting: Take a look at the Determine what makes sense to add to the Flink distribution to help with those use cases that are currently not being serviced, and use the integration of those changes into I am not suggesting that the code in the current entrypoint script should be simply moved elsewhere, because that doesn't actually solve the underlying problem that the way the Flink distribution officially expects to be run and the way it's being run have diverged. As a concrete example, if someone downloads the binary distribution of Flink and tries to run it on a VM, are they expected to set an appropriate |
Well that makes 2 of us. docker-library/official-images#9249 (comment)
docker-library/official-images#9249 (comment)
|
To answer your example: No, it is not required. As for why the kubernetes mode does it: It assembles a plain |
@tianon Note that the stance against blackboxes and against kubernetes-specific branches creates quite a few issues, and at this point I honestly do not know what is acceptable and what isn't. a) I understand the goal of wanting the image to be run anywhere and not containing kubernetes-specific code. |
Actually, I am also confused about what is acceptable to keep in For how to implement kubernetes-specific features, I think we could have a dedicated entrypoint for native Kubernetes integration |
Ok, let me try to phrase this in a simpler way. https://github.com/apache/flink-docker/blob/d2ff00e0176e09cdbbde76412026054016a8551c/1.12/scala_2.12-java11-debian/docker-entrypoint.sh is almost 200 lines long with a lot of little bits of duplicated code. How much of that is actually specific to using Flink in Docker, and how much of that is something that users outside Docker might be interested in / use? It seems like a lot of it is just (explicit, separate) wrappers around other existing Flink scripts, and even many of those are sharing common behavior ( Could they be combined in some way such that the "Docker specific" behavior happens once and the upstream scripts are then just standard fallthrough behavior? For example, right now users do commands like Rough mockup: copy_plugins_if_required
case "$1" in
standalone-job.sh) ... ;;
historyserver.sh) ... ;;
...
esac
exec "$@" If having something that allows users to run something "prettier" like As another explicit example of complexity, instead of disabling jemalloc via an explicit "command" which then has to be stripped and is order-dependent, if that were set via environment variable the logic would be much simpler: if [ -z "${FLINK_DISABLE_JEMALLOC:-}" ]; then
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libjemalloc.so
fi (To make this part of an "official" script in the actual distribution you'll likely want to make it more forgiving / detecting of the path to This isn't as much a matter of "acceptable" vs "unacceptable" but rather that the script is consistently growing in complexity and I'm trying to understand why it is not simpler and/or which parts of it are actually Docker-specific and necessary, because it currently reads as a whole new launcher script for Flink and that seems like something that ought to be part of the Flink distribution instead of something Docker-specific. |
As it stands, I'd say everything. Let's go through it shall we:
There are some things we can certainly simplify (like deduplicating the copy_plugins calls, or jemalloc being controlled by an environment variable (that is in fact already implemented and just needs to be merged)).
I'd beg to differ, given that docker-library/official-images#9249 has now been sitting around for over a month, forcing us to set up a secondary docker image distribution channel. |
Our experience with "we'll fix this in the next version" is that it doesn't happen. The reason we're pushing back on 1.12 is that this functionality is introduced there, and as far as the image is concerned, isn't released yet, so I'm having a hard time understanding why things like the jemalloc usage can't be fixed in 1.12 before the images are released? I get that the kubernetes functionality is unfortunately already baked in to the 1.12 upstream release, so we can't really "fix" that until 1.13. As a compromise (and to show good faith), if we can clean up the jemalloc usage (or instead remove/revert it pending 1.13), I'm happy to merge 1.12 and get that moving under the shared understanding that we find a better usage pattern for kubernetes in 1.13 (cc @yosifkit). |
I can understand that mindset. We're happy to take you up on that compromise; we are cleaning up the script right now with the last PR to be merged today, and will update the official-images PR shortly. |
This PR moves most of the docker-entrypoint.sh logic into a new script within the distribution to reduce the maintenance burden and release issues.
Everything but the jmalloc switch and dropping of privileges has been moved.
Some minor adjustments have been made to the file;
This branch works against a dev flink-docker branch for CI purposes.