Skip to content

Commit b434862

Browse files
committed
Merge remote-tracking branch 'upstream/main' into rhoai-2.22
2 parents 79d890c + 3720755 commit b434862

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

.github/workflows/build-notebooks-pr-rhel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ permissions:
2020
env:
2121
# language=json
2222
contributors: |
23-
["atheo89", "andyatmiami", "caponetto", "daniellutz", "dibryant", "harshad16", "jesuino", "jiridanek", "jstourac", "paulovmr", "Fiona-Waters", "grdryn", "kryanbeane"]
23+
["atheo89", "andyatmiami", "caponetto", "daniellutz", "dibryant", "harshad16", "jesuino", "jiridanek", "jstourac", "paulovmr", "Fiona-Waters", "grdryn", "kryanbeane", "mtchoum1"]
2424
2525
jobs:
2626
gen:

scripts/update-commit-latest-env.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
PROJECT_ROOT = pathlib.Path(__file__).parent.parent
1212

1313

14-
async def get_image_vcs_ref(image_url: str) -> tuple[str, str | None]:
14+
async def get_image_vcs_ref(image_url: str, semaphore: asyncio.Semaphore) -> tuple[str, str | None]:
1515
"""
1616
Asynchronously inspects a container image's configuration using skopeo
1717
and extracts the 'vcs-ref' label.
@@ -32,21 +32,29 @@ async def get_image_vcs_ref(image_url: str) -> tuple[str, str | None]:
3232

3333
logging.info(f"Starting config inspection for: {image_url}")
3434

35+
stdout, stderr, returncode = None, None, None
3536
try:
36-
# Create an asynchronous subprocess
37-
process = await asyncio.create_subprocess_exec(
38-
*command,
39-
stdout=asyncio.subprocess.PIPE,
40-
stderr=asyncio.subprocess.PIPE
41-
)
42-
43-
# Wait for the command to complete and capture output
44-
stdout, stderr = await process.communicate()
45-
46-
# Check for errors
47-
if process.returncode != 0:
48-
logging.error(f"Skopeo command failed for {image_url} with exit code {process.returncode}.")
49-
logging.error(f"Stderr: {stderr.decode().strip()}")
37+
async with semaphore:
38+
logging.info(f"Semaphore acquired, starting skopeo inspect for: {image_url}")
39+
# Create an asynchronous subprocess
40+
process = await asyncio.create_subprocess_exec(
41+
*command,
42+
stdout=asyncio.subprocess.PIPE,
43+
stderr=asyncio.subprocess.PIPE
44+
)
45+
# Wait for the command to complete and capture output
46+
stdout, stderr = await process.communicate()
47+
returncode = process.returncode
48+
49+
# Process the results outside the semaphore block
50+
if returncode != 0:
51+
logging.error(f"Skopeo command failed for {image_url} with exit code {returncode}.")
52+
if stderr:
53+
logging.error(f"Stderr: {stderr.decode().strip()}")
54+
return image_url, None
55+
56+
if not stdout:
57+
logging.error(f"Skopeo command returned success but stdout was empty for {image_url}.")
5058
return image_url, None
5159

5260
# Decode and parse the JSON output from stdout
@@ -67,7 +75,10 @@ async def get_image_vcs_ref(image_url: str) -> tuple[str, str | None]:
6775
logging.error("The 'skopeo' command was not found. Please ensure it is installed and in your PATH.")
6876
return image_url, None
6977
except json.JSONDecodeError:
78+
# This error can now also happen if stdout is None or not valid JSON
7079
logging.error(f"Failed to parse skopeo output as JSON for {image_url}.")
80+
if stdout:
81+
logging.debug(f"Stdout from skopeo for {image_url}: {stdout.decode(errors='replace')}")
7182
return image_url, None
7283
except Exception as e:
7384
logging.error(f"An unexpected error occurred while processing {image_url}: {e}")
@@ -78,7 +89,8 @@ async def inspect(images_to_inspect: typing.Iterable[str]) -> list[tuple[str, st
7889
"""
7990
Main function to orchestrate the concurrent inspection of multiple images.
8091
"""
81-
tasks = [get_image_vcs_ref(image) for image in images_to_inspect]
92+
semaphore = asyncio.Semaphore(22) # Limit concurrent skopeo processes
93+
tasks = [get_image_vcs_ref(image, semaphore) for image in images_to_inspect]
8294
return await asyncio.gather(*tasks)
8395

8496

0 commit comments

Comments
 (0)