Skip to content

Commit

Permalink
Merge pull request #40 from ceph/use-archive-env-var
Browse files Browse the repository at this point in the history
use ARCHIVE_DIR env variable instead of hardcoding /archive_dir/
  • Loading branch information
zmc authored Nov 28, 2023
2 parents c464153 + f87aacb commit fb397d7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ GH_FETCH_MEMBERSHIP_URL='https://api.github.com/user/memberships/orgs/ceph'
## SESSION_SECRET_KEY is used to encrypt session data
## and it's prod value should be kept secret.
SESSION_SECRET_KEY=my-secret-key

# Path where all logs for teuthology-suite or teuthology-kill would be collected
ARCHIVE_DIR=/archive_dir/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ COPY .teuthology.yaml /root
WORKDIR /teuthology_api
COPY . /teuthology_api/
RUN pip3 install -e .
RUN mkdir /archive_dir/

CMD sh /teuthology_api/start_container.sh
1 change: 1 addition & 0 deletions src/teuthology_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class APISettings(BaseSettings):
gh_fetch_membership_url: str = ""

session_secret_key: str = ""
archive_dir: str = ""

model_config = SettingsConfigDict(
env_file=".env", env_file_encoding="utf-8", extra="ignore"
Expand Down
5 changes: 4 additions & 1 deletion src/teuthology_api/services/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import uuid
from pathlib import Path

from fastapi import HTTPException, Request

Expand All @@ -12,6 +13,7 @@
from requests.exceptions import HTTPError

PADDLES_URL = settings.paddles_url
ARCHIVE_DIR = settings.archive_dir

log = logging.getLogger(__name__)

Expand All @@ -22,7 +24,8 @@ def logs_run(func, args):
and return logs printed during the execution of the function.
"""
_id = str(uuid.uuid4())
log_file = f"/archive_dir/{_id}.log"
archive = Path(ARCHIVE_DIR)
log_file = archive / f"{_id}.log"

teuthology_process = Process(target=_execute_with_logs, args=(func, args, log_file))
teuthology_process.start()
Expand Down

0 comments on commit fb397d7

Please sign in to comment.