This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e1f79d  Add a migration to use a logs state directory
7e1f79d is described below

commit 7e1f79da2088e0db4c17af69eef3fc43dc89220f
Author: Sean B. Palmer <[email protected]>
AuthorDate: Mon Jan 19 14:31:51 2026 +0000

    Add a migration to use a logs state directory
---
 atr/admin/__init__.py  | 5 +++--
 atr/config.py          | 2 +-
 atr/server.py          | 7 +++++++
 atr/worker.py          | 6 ++++--
 scripts/README.md      | 2 +-
 scripts/keys_import.py | 2 +-
 start-atr.sh           | 5 +++--
 start-dev.sh           | 5 +++--
 8 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/atr/admin/__init__.py b/atr/admin/__init__.py
index fcaca5c..bef7fb6 100644
--- a/atr/admin/__init__.py
+++ b/atr/admin/__init__.py
@@ -478,7 +478,8 @@ async def keys_update_get(session: web.Committer) -> str | 
web.WerkzeugResponse
         empty=True,
         form_classes="",
     )
-    log_path = pathlib.Path("keys_import.log")
+    # TODO: All known file paths should be constants
+    log_path = pathlib.Path("logs") / "keys-import.log"
     if not await aiofiles.os.path.exists(log_path):
         previous_output = None
     else:
@@ -596,7 +597,7 @@ async def performance(session: web.Committer) -> str:
         raise base.ASFQuartException("APP is not set", errorcode=500)
 
     # Read and parse the performance log file
-    log_path = pathlib.Path("route-performance.log")
+    log_path = pathlib.Path("logs") / "route-performance.log"
     # # Show current working directory and its files
     # cwd = await asyncio.to_thread(Path.cwd)
     # await asyncio.to_thread(APP.logger.info, "Current working directory: 
%s", cwd)
diff --git a/atr/config.py b/atr/config.py
index 844d80a..5c30913 100644
--- a/atr/config.py
+++ b/atr/config.py
@@ -79,7 +79,7 @@ class AppConfig:
     ATTESTABLE_STORAGE_DIR = os.path.join(STATE_DIR, "attestable")
     SQLITE_DB_PATH = decouple.config("SQLITE_DB_PATH", 
default="database/atr.db")
     STORAGE_AUDIT_LOG_FILE = os.path.join(STATE_DIR, "audit", 
"storage-audit.log")
-    PERFORMANCE_LOG_FILE = os.path.join(STATE_DIR, "route-performance.log")
+    PERFORMANCE_LOG_FILE = os.path.join(STATE_DIR, "logs", 
"route-performance.log")
 
     # Apache RAT configuration
     APACHE_RAT_JAR_PATH = decouple.config("APACHE_RAT_JAR_PATH", 
default=f"/opt/tools/apache-rat-{_RAT_VERSION}.jar")
diff --git a/atr/server.py b/atr/server.py
index 092a557..2c4deaf 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -73,6 +73,12 @@ _MIGRATIONS: Final[list[tuple[str, str]]] = [
     ("atr.db", "database/atr.db"),
     ("atr.db-shm", "database/atr.db-shm"),
     ("atr.db-wal", "database/atr.db-wal"),
+    # Logs
+    ("atr-worker.log", "logs/atr-worker.log"),
+    ("atr-worker-error.log", "logs/atr-worker-error.log"),
+    ("hypercorn.log", "logs/hypercorn.log"),
+    ("keys_import.log", "logs/keys-import.log"),
+    ("route-performance.log", "logs/route-performance.log"),
 ]
 
 _SWAGGER_UI_TEMPLATE: Final[str] = """<!DOCTYPE html>
@@ -131,6 +137,7 @@ def _app_dirs_setup(state_dir_str: str, hot_reload: bool) 
-> None:
         pathlib.Path(state_dir_str) / "audit",
         pathlib.Path(state_dir_str) / "cache",
         pathlib.Path(state_dir_str) / "database",
+        pathlib.Path(state_dir_str) / "logs",
         util.get_downloads_dir(),
         util.get_finished_dir(),
         util.get_tmp_dir(),
diff --git a/atr/worker.py b/atr/worker.py
index b1b8f9c..612c5da 100644
--- a/atr/worker.py
+++ b/atr/worker.py
@@ -98,7 +98,8 @@ def _setup_logging() -> None:
     log_format = "[%(asctime)s.%(msecs)03d] [%(process)d] [%(levelname)s] 
%(message)s"
     date_format = "%Y-%m-%d %H:%M:%S"
 
-    logging.basicConfig(filename="atr-worker.log", format=log_format, 
datefmt=date_format, level=logging.INFO)
+    os.makedirs("logs", exist_ok=True)
+    logging.basicConfig(filename="logs/atr-worker.log", format=log_format, 
datefmt=date_format, level=logging.INFO)
 
 
 # Task functions
@@ -309,6 +310,7 @@ if __name__ == "__main__":
     try:
         main()
     except Exception as e:
-        with open("atr-worker-error.log", "a") as f:
+        os.makedirs("logs", exist_ok=True)
+        with open("logs/atr-worker-error.log", "a") as f:
             f.write(f"{datetime.datetime.now(datetime.UTC)}: {e}\n")
             f.flush()
diff --git a/scripts/README.md b/scripts/README.md
index 5fd9712..1572176 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -48,7 +48,7 @@ Detects external access to private interfaces in Python 
modules. Reports any acc
 
 ## keys\_import.py
 
-Imports OpenPGP public keys from ASF committee KEYS files into the ATR 
database. Downloads each committee's `KEYS` file from 
`https://downloads.apache.org/{committee}/KEYS`, parses the keys, and updates 
the database. Logs all activity to `state/keys_import.log`.
+Imports OpenPGP public keys from ASF committee KEYS files into the ATR 
database. Downloads each committee's `KEYS` file from 
`https://downloads.apache.org/{committee}/KEYS`, parses the keys, and updates 
the database. Logs all activity to `state/logs/keys-import.log`.
 
 ## lint/jinja\_route\_checker.py
 
diff --git a/scripts/keys_import.py b/scripts/keys_import.py
index c54d0b9..b026871 100755
--- a/scripts/keys_import.py
+++ b/scripts/keys_import.py
@@ -120,7 +120,7 @@ def log_outcome_errors(outcomes: outcome.List[types.Key], 
committee_name: str) -
 
 @contextlib.contextmanager
 def log_to_file(conf: config.AppConfig):
-    log_file_path = os.path.join(conf.STATE_DIR, "keys_import.log")
+    log_file_path = os.path.join(conf.STATE_DIR, "keys-import.log")
     # This should not be required
     os.makedirs(conf.STATE_DIR, exist_ok=True)
 
diff --git a/start-atr.sh b/start-atr.sh
index 3f2ca33..fee3070 100755
--- a/start-atr.sh
+++ b/start-atr.sh
@@ -11,6 +11,7 @@ then
   python3 scripts/generate-certificates
 fi
 
-echo "Starting hypercorn on ${BIND}" >> /opt/atr/state/hypercorn.log
+mkdir -p /opt/atr/state/logs
+echo "Starting hypercorn on ${BIND}" >> /opt/atr/state/logs/hypercorn.log
 exec hypercorn --worker-class uvloop --bind "${BIND}" \
-  --keyfile key.pem --certfile cert.pem atr.server:app >> 
/opt/atr/state/hypercorn.log 2>&1
+  --keyfile key.pem --certfile cert.pem atr.server:app >> 
/opt/atr/state/logs/hypercorn.log 2>&1
diff --git a/start-dev.sh b/start-dev.sh
index e5da95e..caad114 100755
--- a/start-dev.sh
+++ b/start-dev.sh
@@ -11,6 +11,7 @@ then
   python3 scripts/generate-certificates
 fi
 
-echo "Starting hypercorn on ${BIND}" >> /opt/atr/state/hypercorn.log
+mkdir -p /opt/atr/state/logs
+echo "Starting hypercorn on ${BIND}" >> /opt/atr/state/logs/hypercorn.log
 exec hypercorn --worker-class uvloop --reload --bind "${BIND}" \
-  --keyfile key.pem --certfile cert.pem atr.server:app | tee 
/opt/atr/state/hypercorn.log 2>&1
+  --keyfile key.pem --certfile cert.pem atr.server:app | tee 
/opt/atr/state/logs/hypercorn.log 2>&1


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to