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-release.git


The following commit(s) were added to refs/heads/main by this push:
     new fd24f0d  Restore and improve the rsync analysis task
fd24f0d is described below

commit fd24f0d665b3876fc1da090cce78a8c8be7e49e3
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Mar 21 18:54:14 2025 +0200

    Restore and improve the rsync analysis task
---
 atr/ssh.py         | 43 ++++++++++++++++++++-----------------------
 atr/tasks/rsync.py | 14 ++++++++++----
 2 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/atr/ssh.py b/atr/ssh.py
index 14bd2f9..f902543 100644
--- a/atr/ssh.py
+++ b/atr/ssh.py
@@ -22,7 +22,6 @@ import asyncio.subprocess
 import logging
 import os
 import string
-import uuid
 from typing import Final
 
 import aiofiles
@@ -196,8 +195,8 @@ def _command_simple_validate(argv: list[str]) -> str | None:
     return None
 
 
-async def _command_validate(process: asyncssh.SSHServerProcess) -> list[str] | 
None:
-    def fail(message: str) -> list[str] | None:
+async def _command_validate(process: asyncssh.SSHServerProcess) -> tuple[str, 
str, list[str]] | None:
+    def fail(message: str) -> tuple[str, str, list[str]] | None:
         # NOTE: Changing the return type to just None really confuses mypy
         _LOGGER.error(message)
         process.stderr.write(f"ATR SSH error: {message}\nCommand: 
{process.command}\n".encode())
@@ -253,7 +252,7 @@ async def _command_validate(process: 
asyncssh.SSHServerProcess) -> list[str] | N
     # Create the release's storage directory if it doesn't exist
     await aiofiles.os.makedirs(argv[path_index], exist_ok=True)
 
-    return argv
+    return path_project, path_version, argv
 
 
 async def _handle_client(process: asyncssh.SSHServerProcess) -> None:
@@ -261,9 +260,10 @@ async def _handle_client(process: 
asyncssh.SSHServerProcess) -> None:
     asf_uid = process.get_extra_info("username")
     _LOGGER.info(f"Handling command for authenticated user: {asf_uid}")
 
-    argv = await _command_validate(process)
-    if not argv:
+    validation_results = await _command_validate(process)
+    if not validation_results:
         return
+    project_name, release_version, argv = validation_results
 
     try:
         # Create subprocess to actually run the command
@@ -283,24 +283,21 @@ async def _handle_client(process: 
asyncssh.SSHServerProcess) -> None:
         exit_status = await proc.wait()
 
         # Start a task to process the new files
-        # TODO: Turned this off for now, because we need to decide on the 
workflow
-        start_task = False
-        if start_task:
-            async with db.session() as data:
-                async with data.begin():
-                    from atr.tasks.rsync import Analyse
-
-                    upload_uuid = str(uuid.uuid4()).replace("-", "")
-                    project_name = "test"
-                    data.add(
-                        models.Task(
-                            status=models.TaskStatus.QUEUED,
-                            task_type="rsync_analyse",
-                            task_args=Analyse(
-                                asf_uid=asf_uid, upload_uuid=upload_uuid, 
project_name=project_name
-                            ).model_dump(),
-                        )
+        async with db.session() as data:
+            async with data.begin():
+                from atr.tasks.rsync import Analyse
+
+                data.add(
+                    models.Task(
+                        status=models.TaskStatus.QUEUED,
+                        task_type="rsync_analyse",
+                        task_args=Analyse(
+                            asf_uid=asf_uid,
+                            project_name=project_name,
+                            release_version=release_version,
+                        ).model_dump(),
                     )
+                )
         # Exit the SSH process with the same status as the rsync process
         process.exit(exit_status)
 
diff --git a/atr/tasks/rsync.py b/atr/tasks/rsync.py
index ddbe601..da21777 100644
--- a/atr/tasks/rsync.py
+++ b/atr/tasks/rsync.py
@@ -31,18 +31,24 @@ class Analyse(pydantic.BaseModel):
     """Parameters for rsync analysis."""
 
     asf_uid: str = pydantic.Field(..., description="ASF UID of the user to 
rsync from")
-    upload_uuid: str = pydantic.Field(..., description="UUID of the upload to 
rsync")
     project_name: str = pydantic.Field(..., description="Name of the project 
to rsync")
+    release_version: str = pydantic.Field(..., description="Version of the 
release to rsync")
 
 
 async def analyse(args: dict[str, Any]) -> tuple[models.TaskStatus, str | 
None, tuple[Any, ...]]:
     """Analyse an rsync upload."""
     data = Analyse(**args)
-    task_results = task.results_as_tuple(await _analyse_core(data.asf_uid, 
data.upload_uuid, data.project_name))
-    _LOGGER.info(f"Analyse {data.upload_uuid} for {data.project_name}")
+    task_results = task.results_as_tuple(
+        await _analyse_core(
+            data.asf_uid,
+            data.project_name,
+            data.release_version,
+        )
+    )
+    _LOGGER.info(f"Analyse {data.project_name} {data.release_version}")
     return task.COMPLETED, None, task_results
 
 
-async def _analyse_core(asf_uid: str, upload_uuid: str, project_name: str) -> 
str:
+async def _analyse_core(asf_uid: str, project_name: str, release_version: str) 
-> str:
     """Analyse an rsync upload."""
     return analysis.perform.__name__


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

Reply via email to