Skip to content
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

YQ kqprun added scripts for starting prometheus and connector #14816

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

GrigoriyPA
Copy link
Collaborator

@GrigoriyPA GrigoriyPA commented Feb 19, 2025

Changelog entry

Added scripts for starting prometheus and connector in kqprun

Changelog category

  • Improvement

Description for reviewers

Copy link

github-actions bot commented Feb 19, 2025

🟢 2025-02-19 21:04:21 UTC The validation of the Pull Request description is successful.

Copy link

github-actions bot commented Feb 19, 2025

2025-02-19 21:05:50 UTC Pre-commit check linux-x86_64-release-asan for d8d7fd7 has started.
2025-02-19 21:06:40 UTC Artifacts will be uploaded here
2025-02-19 21:08:57 UTC ya make is running...
🟢 2025-02-19 21:09:14 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-02-19 21:09:26 UTC Build successful.

Copy link

github-actions bot commented Feb 19, 2025

2025-02-19 21:12:30 UTC Pre-commit check linux-x86_64-relwithdebinfo for d8d7fd7 has started.
2025-02-19 21:14:28 UTC Artifacts will be uploaded here
2025-02-19 21:16:49 UTC ya make is running...
🟢 2025-02-19 21:16:58 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-02-19 21:17:03 UTC Build successful.

Copy link

github-actions bot commented Feb 20, 2025

2025-02-20 07:20:43 UTC Pre-commit check linux-x86_64-release-asan for 0ba5e02 has started.
2025-02-20 07:20:51 UTC Artifacts will be uploaded here
2025-02-20 07:23:11 UTC ya make is running...
🟢 2025-02-20 07:23:17 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-02-20 07:23:23 UTC Build successful.

Copy link

github-actions bot commented Feb 20, 2025

2025-02-20 07:23:51 UTC Pre-commit check linux-x86_64-relwithdebinfo for 0ba5e02 has started.
2025-02-20 07:24:02 UTC Artifacts will be uploaded here
2025-02-20 07:26:25 UTC ya make is running...
🟢 2025-02-20 07:26:30 UTC Tests successful.

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-02-20 07:26:36 UTC Build successful.


ydb:
<<: *data_source_default_var
use_underlay_network_for_dedicated_databases: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mode: MODE_QUERY_SERVICE_NATIVE
see ydb/library/yql/providers/generic/connector/tests/fq-connector-go/fq-connector-go.yaml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну вот о чём и речь - начинаются проблемы консистентности конфигов, их обновления, тогда как об этом вообще не надо думать. Рабочий конфиг идёт прямо в образе, и не надо его трогать без надобности


SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)

cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"${2:-...}"

SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)

cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml
sed -i "s/\${TARGET_PORT}/$1/g" ./connector_config.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or drop cp line above and
sed "s/.../" "${2:-...}" > ./connector_config.yaml
in single step

cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml
sed -i "s/\${TARGET_PORT}/$1/g" ./connector_config.yaml

docker run --rm --name=fq-connector-go-$1 --network host -v ./connector_config.yaml:/opt/ydb/cfg/fq-connector-go.yaml ghcr.io/ydb-platform/fq-connector-go:latest
Copy link
Member

@vitalyisaev2 vitalyisaev2 Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Не совсем понятно, зачем коннектору --network=host? Ведь вряд ли кто-то будет ходить в коннектор извне, кроме kqprun, который будет работать на той же машине, что и контейнер с коннектором. Да даже если надо ходить - всё равно стандартный паттерн это docker run -d -p <host_ip>:<host_port>:<container_port> <image_name>. Можешь попробовать развернуть какой-нибудь Nginx и сходить на него с другой машины. Если не заработает - это значит, что какие-то яндексовские велосипеды в области файрволла блокируют сетевую доступность, и надо просить Вадима их поправить. Поэтому ты можешь использовать просто стандартные настройки сети (т. е. вообще не указывать параметр --network), но вместо этого указать маппинг порта коннектора в тот, что тебе нужен, типа docker run -p внешний_порт:внутренний_порт .... Когда всё правильно настроено на хосте, --network=host никогда не нужен.
  2. Исходя из п. 1, тебе не нужен кастомный конфиг коннектора: не нужно его рендерить из шаблона и не нужно монтировать в контейнер. Внутри образа с коннектором уже есть дефолтный конфиг, и, как мне кажется, его здесь будет вполне достаточно.

cp ${3:-"$SCRIPT_DIR/configuration/prometheus_config.yaml"} ./prometheus_config.yaml
sed -i "s/\${TARGET_PORT}/$1/g" ./prometheus_config.yaml

docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё вышесказанное относится и к контейнеру с Prometheus в том числе.

cp ${3:-"$SCRIPT_DIR/configuration/prometheus_config.yaml"} ./prometheus_config.yaml
sed -i "s/\${TARGET_PORT}/$1/g" ./prometheus_config.yaml

docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2
docker run --rm --name=prometheus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2

if netstat -tuln | grep ":$1"; then
echo "Can not start connector on port $1, port already in use"
exit -1
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы сказал, что это лишняя работа. Если хостовый порт занят, docker и так выдаст человекочитаемую ошибку.

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кмк, не хватает скриптов, которые будут гасить все эти контейнеры. Ведь у контейнеров, как я вижу, ещё и имена с переменными суффиксами.

Возможно, тебе более удобным покажется такой подход. Делаешь docker-compose.yml с нужными тебе переменными параметрами:

   version: '3.8'

   services:
     web:
       image: my_service:my_tag
       ports:
         - "${HOST_PORT}:80"

Далее в баш скриптах просто вызов с указанием переменных окружения:

# запуск
HOST_PORT=12345 docker compose up -d web 
# остановка
docker compose down -v web

Так можно параметризировать самые разнообразные настройки, в том числе имя контейнера. Баш скрипты становятся лаконичными, а, всё, что связано с Docker, уходит в docker-compose.yaml, что является стандартным и переносимым способом настройки окружений.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants