-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Add docker-entrypoint-initdb.d support #3695
Add docker-entrypoint-initdb.d support #3695
Conversation
Solves #3319. |
As alternative port readiness check for the client can be performed in something like this: while true; do
timeout 1 bash -c 'cat < /dev/null > /dev/tcp/localhost/9000' 2>1 /dev/null;
rv=$?
if [[ $rv = 0 ]]; then
break
fi
done I don't know which approach is better sleep or this cycle. |
#!/bin/bash | ||
set -e | ||
|
||
clickhouse client -n <<-EOSQL |
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.
Better use clickhouse-client
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 is no clickhouse-client
binary inside the clickhouse-server
image.
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.
And that is very confusing. IMHO client should be added to server container. It costs nothing (just a symlink) but makes usage of clickhouse-client much more logical.
pid="$!" | ||
sleep 1 | ||
|
||
clickhouseclient=( clickhouse client --multiquery ) |
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.
Don't understand, why we need array here.
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 see. In the postgres/mysql entrypoints password and database added later in script. This can be useful for future *_PASSWORD
and *_USER
variables support.
Array is redundant right now. I can change it to simple variable.
With current approach we have race condition.
With this approach we have possibility of infinite loop without any diagnostics. |
I can make another PR with port readiness probe within 10 retries. @alexey-milovidov should I? |
That will leave "warning" in the log file, something like that:
Some users are quite nervous about such warnings... :\ In some scanrios (for example, if docker uses real network instead of NAT) it can give false match, or will never succeed. So port should not be hardcoded there. Possible alternatives:
Also instead of parametrizing the port, you can extract it from config, like that: clickhouse-extract-from-config --config-file /etc/clickhouse-server/config.xml --key=tcp_port
clickhouse-extract-from-config --config-file /etc/clickhouse-server/config.xml --key=http_port summarizeFor me that option looks the most straight ahead (easy to understand, no warnings, use wget possibilities to do retries with max number of retries, wget is avaliable in most of containers) CLICKHOUSE_HTTP_PORT=$(clickhouse-extract-from-config --config-file /etc/clickhouse-server/config.xml --key=http_port)
wget --server-response --spider --quiet --tries=20 --waitretry=1 --retry-connrefused "http://localhost:$CLICKHOUSE_HTTP_PORT/ping" && echo 'ok' || echo "ups" |
And also, while we are here - it's better to change those lines: |
Docker fixes (related to #3695)
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
This done in postgres entrypoint in the same way: https://github.com/docker-library/postgres/tree/master/11.
The most tricky part is starting clickhouse-server in detached mode and sleeping 1 second after it