Skip to content

Commit

Permalink
Merge remote-tracking branch 'kirillgarbar/main' into log-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgarbar committed Sep 24, 2024
2 parents 456fb2c + 5ad082b commit 8871af3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ $(INSTALL_DEPS_STAMP): $(VENV_DIR) pyproject.toml poetry.lock
@if [[ -n "${UPDATE_POETRY_LOCK}" ]]; then \
$(POETRY) update --lock; \
fi
# Fix "TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'"
# Related issue https://github.com/pypa/setuptools/issues/4483
# TODO: Try to remove this workaround after upgrading Poetry and Python version
$(VENV_DIR)/bin/pip install "setuptools<71"
$(POETRY) install --no-root
touch $(INSTALL_DEPS_STAMP)

Expand Down
2 changes: 2 additions & 0 deletions ch_tools/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
},
"zookeeper": {
"randomize_hosts": True,
"username": None,
"password": None,
},
"chadmin": {
"wait": {
Expand Down
31 changes: 23 additions & 8 deletions ch_tools/monrun_checks_keeper/keeper_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from click import command, option, pass_context
from kazoo.client import KazooClient
from kazoo.security import make_digest_acl

from ch_tools.common.clickhouse.config import ClickhouseKeeperConfig
from ch_tools.common.result import CRIT, OK, WARNING, Result
Expand All @@ -27,14 +28,28 @@ def alive_command(ctx):
"""Check (Zoo)Keeper service is alive"""
try:
keeper_port, use_ssl = get_keeper_port_pair()
client = KazooClient(
f"127.0.0.1:{keeper_port}",
connection_retry=ctx.obj.get("retries"),
command_retry=ctx.obj.get("retries"),
timeout=ctx.obj.get("timeout"),
use_ssl=use_ssl,
verify_certs=not ctx.obj.get("no_verify_ssl_certs"),
)
username = ctx.obj["config"]["zookeeper"]["username"]
password = ctx.obj["config"]["zookeeper"]["password"]
args = {
"hosts": f"127.0.0.1:{keeper_port}",
"connection_retry": ctx.obj.get("retries"),
"command_retry": ctx.obj.get("retries"),
"timeout": ctx.obj.get("timeout"),
"use_ssl": use_ssl,
"verify_certs": not ctx.obj.get("no_verify_ssl_certs"),
}
if username is not None and password is not None:
auth_data = [
(
"digest",
f"{username}:{password}",
)
]
acls = [make_digest_acl(username, password, all=True)]
args["auth_data"] = auth_data
args["default_acl"] = acls

client = KazooClient(**args)
client.start()
client.get("/")
client.create(path="/{0}_alive".format(socket.getfqdn()), ephemeral=True)
Expand Down

0 comments on commit 8871af3

Please sign in to comment.