fix(vedastro): pin SDK at install and cap free-tier wait
Image build patches vedastro.check_for_update to a no-op after pip install so import cannot hit pypi or upgrade the pin. Free-tier queue waits are capped to VEDASTRO_TIMEOUT_SECONDS and fail fast as free_tier_rate_limited. Gateway status exposes runtime mode as booleans without secrets. BUG-719 resolved; BUG-720 stays investigating until production env is filled in.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Neutralize vedastro SDK import-time PyPI upgrade. Fail the image build if the hook is missing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
NOOP_SOURCE = 'def check_for_update(package_name="vedastro"):\n return None\n'
|
||||
|
||||
|
||||
def patch_update_check(path: Path) -> None:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
if "def check_for_update" not in text:
|
||||
raise SystemExit(f"{path} does not define check_for_update")
|
||||
path.write_text(NOOP_SOURCE, encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
spec = importlib.util.find_spec("vedastro.update_check")
|
||||
if spec is None or not spec.origin:
|
||||
print("vedastro.update_check is not installed", file=sys.stderr)
|
||||
return 1
|
||||
path = Path(spec.origin)
|
||||
patch_update_check(path)
|
||||
print(f"neutralized {path}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -6,11 +6,12 @@ ENV PYTHONUNBUFFERED=1 \
|
||||
PIP_DEFAULT_TIMEOUT=60
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt ./
|
||||
COPY requirements.txt deploy/patch_vedastro_update_check.py ./
|
||||
RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 update \
|
||||
&& apt-get install -y --no-install-recommends build-essential nodejs \
|
||||
&& python -m pip install -r requirements.txt \
|
||||
&& python patch_vedastro_update_check.py \
|
||||
&& apt-get purge -y --auto-remove build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user