sync @ 88a1d74
This commit is contained in:
@@ -743,6 +743,10 @@ def _rewrite_prometheus_scrapes(host_dir, doc, env_path) -> None:
|
||||
Di sini diganti `<alamat-eksternal>:<MINIO_INTERNAL_PORT>`.
|
||||
|
||||
MinIO se-host (single-host / P1) → tak diubah (`minio:9000`, satu jaringan Docker).
|
||||
|
||||
Address boleh ber-URL penuh (`https://minio.corp:9000`): target ditulis `host:port`
|
||||
(TANPA skema, tanpa port dobel) dan `scheme:` job minio disamakan (https) agar scrape
|
||||
tak menembak http ke port TLS.
|
||||
"""
|
||||
yml = host_dir / "config" / "prometheus" / "prometheus.yml"
|
||||
if not yml.is_file():
|
||||
@@ -750,9 +754,31 @@ def _rewrite_prometheus_scrapes(host_dir, doc, env_path) -> None:
|
||||
ext = inventory.external_address(doc, "minio")
|
||||
if not ext:
|
||||
return
|
||||
port = _source_env_value(env_path, "MINIO_INTERNAL_PORT") or "9000"
|
||||
scheme, host, p = inventory.parse_address(ext)
|
||||
if scheme:
|
||||
target = f"{host}:{p}" if p else host
|
||||
eff_scheme = scheme
|
||||
else:
|
||||
# alamat polos (IP/hostname) → port internal, perilaku lama; skema ikut S3_ENDPOINT
|
||||
port = _source_env_value(env_path, "MINIO_INTERNAL_PORT") or "9000"
|
||||
target = f"{host}:{port}"
|
||||
eff_scheme = ((_source_env_value(env_path, "S3_ENDPOINT") or "").split("://", 1)[0]
|
||||
or "http")
|
||||
txt = yml.read_text(encoding="utf-8")
|
||||
new = txt.replace("minio:9000", f"{ext}:{port}")
|
||||
out: list[str] = []
|
||||
in_minio = False
|
||||
for line in txt.splitlines():
|
||||
s = line.strip()
|
||||
if s.startswith("- job_name:"):
|
||||
in_minio = s.split(":", 1)[1].strip() in ("minio", "minio-bucket")
|
||||
if "minio:9000" in line:
|
||||
line = line.replace("minio:9000", target)
|
||||
if in_minio and s == "scheme: http" and eff_scheme != "http":
|
||||
line = line.replace("scheme: http", f"scheme: {eff_scheme}")
|
||||
out.append(line)
|
||||
new = "\n".join(out)
|
||||
if txt.endswith("\n"):
|
||||
new += "\n"
|
||||
if new != txt:
|
||||
yml.write_text(new, encoding="utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user