Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust testrunner validation retry logic #80

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python/src/etos_api/library/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ async def authorize(
else:
query[key] = value.strip('"')

if not url:
raise ValueError(f"No realm found in www-authenticate header: {www_auth_header}")
if not isinstance(url, str) or not (
url.startswith("http://") or url.startswith("https://")
):
raise ValueError(f"No realm URL found in www-authenticate header: {www_auth_header}")

async with session.get(url, params=query) as response:
response.raise_for_status()
Expand Down
22 changes: 11 additions & 11 deletions python/src/etos_api/library/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""ETOS API suite validator module."""
import logging
import asyncio
import random
from typing import List, Union
from uuid import UUID

Expand Down Expand Up @@ -198,18 +197,19 @@ async def validate(self, test_suite_url):
test_runners.add(constraint.value)
docker = Docker()
for test_runner in test_runners:
for attempt in range(3):
for attempt in range(5):
if attempt > 0:
span.add_event(f"Test runner validation unsuccessful, retry #{attempt}")
self.logger.warning(
"Test runner %s validation unsuccessful, retry #%d",
test_runner,
attempt,
)
result = await docker.digest(test_runner)
if result:
break
span.add_event(
f"Test runner validation unsuccessful, retrying {3 - attempt} more times"
)
self.logger.warning(
"Test runner %s validation unsuccessful, retrying %d more times",
test_runner,
3 - attempt,
)
await asyncio.sleep(random.randint(1, 3))
# Total wait time with 5 attempts: 55 seconds
sleep_time = (attempt + 1) ** 2
await asyncio.sleep(sleep_time)

assert result is not None, f"Test runner {test_runner} not found"
Loading