From 5a99fa46fd74f83e5f7adc1dce1c1b8723d189ec Mon Sep 17 00:00:00 2001 From: zhx Date: Fri, 22 May 2026 14:23:10 +0800 Subject: [PATCH] support dashboard cdc mysql credentials --- monitors/yumi/service_release.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/monitors/yumi/service_release.py b/monitors/yumi/service_release.py index 379d8cb..98b5930 100644 --- a/monitors/yumi/service_release.py +++ b/monitors/yumi/service_release.py @@ -1364,19 +1364,25 @@ def render_dashboard_cdc_env() -> str: from .nacos import current_namespace, get_config_content namespace_id, _ = current_namespace() - content = get_config_content(namespace_id, "common", "rds-config.yml") + rds_content = get_config_content(namespace_id, "common", "rds-config.yml") + try: + cdc_content = get_config_content(namespace_id, "common", "dashboard-cdc-worker.yml") + except Exception: # noqa: BLE001 + cdc_content = "" - def yaml_value(key: str) -> str: + def yaml_value(content: str, key: str, *, required: bool = True) -> str: match = re.search(rf"(?im)^\s*{re.escape(key)}\s*:\s*(.*?)\s*$", content) if not match: - raise RuntimeError(f"missing {key} in common/rds-config.yml") + if required: + raise RuntimeError(f"missing {key} in nacos mysql config") + return "" value = match.group(1).strip() if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")): value = value[1:-1] return value jdbc_url = ( - yaml_value("url") + yaml_value(rds_content, "url") .replace("jdbc:p6spy:mysql://", "mysql://", 1) .replace("jdbc:mysql://", "mysql://", 1) ) @@ -1384,8 +1390,8 @@ def render_dashboard_cdc_env() -> str: if not parsed.hostname: raise RuntimeError("invalid rds-config url for dashboard cdc worker") - username = yaml_value("username") - password = yaml_value("password") + username = yaml_value(cdc_content, "username", required=False) or yaml_value(rds_content, "username") + password = yaml_value(cdc_content, "password", required=False) or yaml_value(rds_content, "password") database = parsed.path.lstrip("/") or "likei" addr = f"{parsed.hostname}:{parsed.port or 3306}" dsn = (