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

Add retry for testrunner validation #65

Merged
merged 6 commits into from
Jun 26, 2024
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
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kubernetes~=26.1
sse-starlette~=1.6
opentelemetry-api~=1.21
opentelemetry-exporter-otlp~=1.21
opentelemetry-instrumentation-fastapi~=0.45b0
opentelemetry-instrumentation-fastapi==0.46b0
opentelemetry-sdk~=1.21
jsontas~=1.4
packageurl-python~=0.11
Expand Down
2 changes: 1 addition & 1 deletion python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install_requires =
sse-starlette~=1.6
opentelemetry-api~=1.21
opentelemetry-exporter-otlp~=1.21
opentelemetry-instrumentation-fastapi~=0.45b0
opentelemetry-instrumentation-fastapi==0.46b0
opentelemetry-sdk~=1.21
jsontas~=1.4
packageurl-python~=0.11
Expand Down
22 changes: 19 additions & 3 deletions python/src/etos_api/library/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
"""ETOS API suite validator module."""
import logging
import asyncio
import random
from typing import List, Union
from uuid import UUID

Expand All @@ -24,6 +26,7 @@
from pydantic import BaseModel # pylint:disable=no-name-in-module
from pydantic import ValidationError, conlist, constr, field_validator
from pydantic.fields import PrivateAttr
from opentelemetry import trace

from etos_api.library.docker import Docker

Expand Down Expand Up @@ -179,6 +182,7 @@ async def validate(self, test_suite_url):
:type test_suite_url: str
:raises ValidationError: If the suite did not validate.
"""
span = trace.get_current_span()
downloaded_suite = await self._download_suite(test_suite_url)
for suite_json in downloaded_suite:
test_runners = set()
Expand All @@ -191,6 +195,18 @@ async def validate(self, test_suite_url):
test_runners.add(constraint.value)
docker = Docker()
for test_runner in test_runners:
assert (
await docker.digest(test_runner) is not None
), f"Test runner {test_runner} not found"
for attempt in range(3):
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))

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