Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Download agent logs using sas url (#1920)
Browse files Browse the repository at this point in the history
  • Loading branch information
tevoinea authored May 10, 2022
1 parent 78c680e commit 779a67e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .devcontainer/post-create-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ echo "Restore dotnet dependencies"
cd /workspaces/onefuzz/src/ApiService
dotnet restore

sudo apt-get install direnv
sudo apt-get install direnv uuid-runtime
pip install wheel

echo "Setting up venv"
cd /workspaces/onefuzz/src
Expand All @@ -53,3 +54,7 @@ direnv allow
pip install -r requirements-dev.txt
cd __app__
pip install -r requirements.txt

cd /workspaces/onefuzz/src/utils
chmod u+x lint.sh
pip install types-six
13 changes: 10 additions & 3 deletions src/cli/onefuzz/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ def get(
"""

from typing import cast
from urllib import parse

if job_id is None:
if task_id is None:
Expand All @@ -658,10 +659,11 @@ def get(
if machine_id is not None:
file_path += f"{machine_id}/"

token_credential = AzureCliCredential()
container_name = parse.urlsplit(container_url).path[1:]
container = self.onefuzz.containers.get(container_name)

container_client: ContainerClient = ContainerClient.from_container_url(
container_url, credential=token_credential
container.sas_url
)

blobs = container_client.list_blobs(name_starts_with=file_path)
Expand All @@ -683,7 +685,12 @@ def __init__(self, name: str, creation_time: datetime):

files.sort(key=lambda x: x.creation_time, reverse=True)

self.logger.info(f"Found {len(files)} matching files to download")
num_files = len(files)
if num_files > 0:
self.logger.info(f"Found {len(files)} matching files to download")
else:
self.logger.info("Did not find any matching files to download")
return None

if not all:
self.logger.info(f"Downloading only the {last} most recent files")
Expand Down

0 comments on commit 779a67e

Please sign in to comment.